As far as a practical answer, you shouldn’t be counting words yourself anyway. Use the tool built into your word processor or paste your text into an online tool like this one.
In either case, the count will be determined mostly by spaces, consistent with this definition:
- a unit of language, consisting of one or more spoken sounds or their written representation, that functions as a principal carrier of meaning. Words are composed of one or more morphemes and are either the smallest units susceptible of independent use or consist of two or three such units combined under certain linking conditions, as with the loss of primary accent that distinguishes “blackbird” from “black bird”. Words are usually separated by spaces in writing, and are distinguished phonologically, as by accent, in many languages.
Source: dictionary.com definitions for “word”
The teacher you remember saying that “cannot” is two words was probably speaking in some other context. Technically speaking, “cannot” is a contraction of the words “can” and “not”, but it would be somewhat difficult to defend the stance that the statement “fish cannot sing” has four words in it where most native speakers would count three. Similarly, nobody is helped in thinking that “runaway boxcar” consists of more than two words. Presently, “cannot” is its own word with its own definition, even if that definition is “can not”.
“Big-hearted” also has its own definition, and M-W doesn’t even bother with the hyphen. This is a good example of what the definition of “word” above calls “a principal carrier of meaning”. If your hyphens are well placed and meaningful, they should cause the words they join to communicate a new concept—something the two words weren’t saying when they were separate. That means that your hyphenated creation is now “the smallest isolable meaningful element”, also known as a single word. The key here is that the meaning comes as a package, not as one element modifying another within a sentence (such as could potentially be rewritten with the words even farther apart).
In school assignments, word count requirements can usually be thought of as guidelines; they are meant to provide an approximation of the desired length. Some instructors might be more specific if they want to restrict the length of students’ writing with a word-count limit, and some might specify that they want at least a certain number of words on a topic if they are worried students will not write enough. If they don’t specify either way, it usually means there’s some wiggle room and any essay reasonably close to the word count will be accepted. If you’re worried about it you can make sure you are over the number, but I believe most instructors would prefer a submission that is slightly shorter than the assigned count over one that goes over the number because it contains unnecessary fluff (this is assuming they bother to check the length this closely at all). The other criteria for the assignment are much more important; word counts just give you an idea of how much detail to include while answering the question.