TITLE: Six letter words from "MONSTER"
QUESTION [8 upvotes]: A six letter word is formed using the letters of the word "MONSTER", with or without repetition. The number of words that contain exactly three different letters is?
I tried computing the possible number of words using Python, keeping the conditions in mind, and got an answer of around $18900$. But while thinking about it by theoretical methods, I first choose $3$ letters from $7$ in $\binom73$ ways, and then arranged those $3$ in $6$ places in $3^6$ ways, and then removed the $3$ cases where the whole word is made up of one letter, along with those $3(2^6)$ cases where the word was made up of only two letters among the three chosen.  
Sorry if it's confusing, but any kind of help would be really appreciated.
Thank you.
Any helpful resources for discrete mathematics would also be appreciated.

REPLY [5 votes]: You have to add the 3 cases in which the word is made of one single letter, not subtract them! 
$3^6$ is the total number of words made of 1, 2, or 3 letters.
$3 \cdot 2^6$ is the total number of words made of 1 or 2 letters, but you are counting each word made of 1 letter twice: once you have fixed a triple of letters {A,B,C}, you can get AAAAAA in two ways, one by selecting {A,B} as your two-letter subset, and one by selecting {A,C}.
So you have subtracted the words made of 1 letter twice, and you have to add them back.
This is an example of the inclusion-exclusion principle at work.
Indeed, $\binom{7}{3}(3^6-3\cdot 2^6+3) = 18900$.