More precise generic formulation of the problem:
Given an alphabet of $A$ different letters, how many $K$ length words can we form that have exactly $D$ different letters?
Example:
Given $\{a,b,c,d,e,f\}$ as the alphabet (for $A = 6$), how many $5$ letter words (for $K = 5$) can we form that have exactly $3$ different letters (for $D = 3$)?
So a couple of such words would be:
$$ abddd, adbdd, abeee, abfff, abbcc, abcbc, afafb, fabbf $$
...etc
Any suggestion to look for the shortest general solution is appreciated.