<s>[INST] how many strings of length 21 from letters {D,L,O} with repetition that have DOLL appearing only once The word DOLL has length $4$. There will be $18$ possible positions where 'DOLL' can appear, each with $3^{17}$ choices. So there will $18 \cdot 3^{17}$ cases where it can appear at least once. But I also know that there will be many duplicates in this approach. How do I go about removing them. 
I can count those 


*

*With DOLL appearing at least / only $5$ times as $\binom{6}{5}$ each with $3^{21-4 \cdot 5} = 3$ choices.

*With DOLL appearing at least $4$ times as 


*

*$21$ positions to place DOLL first time

*$17$ positions to place DOLL second time

*$13$ positions to place DOLL third time

*$9$ positions to place DOLL fourth time

*all with $3^{5}$ choices, so this gives $21 \cdot 17 \cdot 13 \cdot 9 \cdot 3^5$ possibilities

*if I subtract all the choices that have $5$ occurrences of DOLL ($\binom{6}{5} \cdot 3$)from this, I will get only those that have $4$ occurrences of DOLL



But from here on how do I proceed for calculating $3$, $2$ and only $1$ occurrences. Do I apply the inclusion exclusion principle at each step or only when calculating for at most $1$ occurrence of DOLL.
 [/INST] (This is simply a supplement to the two previous answers.)
As shown in N.F. Taussig's answer, the number of words with DOLL appearing at least once is given by 
$\hspace{.5 in}\displaystyle\binom{18}{1}3^{17} - \binom{15}{2}3^{13} + \binom{12}{3}3^9 - \binom{9}{4}3^5 + \binom{6}{5}3=2,161,418,679$
Similarly, the number of words in which DOLL appears at least twice is given by
$\hspace{.5 in}\displaystyle\binom{15}{2}3^{13} -\binom{2}{1} \binom{12}{3}3^9 +\binom{3}{1} \binom{9}{4}3^5 -\binom{4}{1} \binom{6}{5}3=158,835,177$
Subtracting, we get $2,002,583, 502$ words in which DOLL appears exactly once, 
as shown in joriki's answer.
</s>