Word limit plugin?

Would it be possible to make a plugin to limit a document to a fixed number of words? For example, if I’m writing from a 500 word prompt, I would want the document to contain no more than 500 words.