This is a vast subject. I will try to limit the number of words I expend on it so as not to use up too great an amount of space. The confusion between the two categories of words relating to amount and number is so pervasive that those of us who still distinguish between them constitute an endangered species; but if you want to avoid our ire, learn the difference. Amount words relate to quantities of things that are measured in bulk; number to things that can be counted.
In the second sentence above, it would have been improper to write “the amount of words” because words are discrete entities which can be counted, or numbered.
Here is a handy chart to distinguish the two categories of words:
You can eat fewer cookies, but you drink less milk. If you eat too many cookies, people would probably think you’ve had too much dessert. If the thing being measured is being considered in countable units, then use number words. Even a substance which is considered in bulk can also be measured by number of units. For instance, you shouldn’t drink too much wine, but you should also avoid drinking too many glasses of wine. Note that here you are counting glasses. They can be numbered.
The most common mistake of this kind is to refer to an “amount” of people instead of a “number” of people.
Just to confuse things, “more” can be used either way: you can eat more cookies and drink more milk.
Exceptions to the less/fewer pattern are references to units of time and money, which are usually treated as amounts: less than an hour, less than five dollars. Only when you are referring to specific coins or bills would you use fewer: “I have fewer than five state quarters to go to make my collection complete.”