Given an alphabet of $k$ symbols, $\{{s}_{1},{s}_{2},\dots ,{s}_{k}\}$, how many words of length $n$, $w(n)$, can be generated knowing that,

Only two of the $k$ available symbols participate;

The symbol ${s}_{i}$ must appear exactly ${n}_{i}$ times and the symbol ${s}_{j}$ must appear exactly ${n}_{j}$ times and ${n}_{i}+{n}_{j}=n$ (the length of the word);

To ilustrate the problem suppose that the alphabet is $\{A,B,C\}$ and that I want words of length $4$ with two $A$ and two $B$. With the stated restrictions all of the possible words are

$\{AABB,ABAB,ABBA,BBAA,BAAB,BABA\}$

So, I need to know what this $w(n)=w({n}_{i},{n}_{j})$ is. Some references on aproaches on how to solve this kind of problems and related algorithms to generate such words would be apreciated.

Only two of the $k$ available symbols participate;

The symbol ${s}_{i}$ must appear exactly ${n}_{i}$ times and the symbol ${s}_{j}$ must appear exactly ${n}_{j}$ times and ${n}_{i}+{n}_{j}=n$ (the length of the word);

To ilustrate the problem suppose that the alphabet is $\{A,B,C\}$ and that I want words of length $4$ with two $A$ and two $B$. With the stated restrictions all of the possible words are

$\{AABB,ABAB,ABBA,BBAA,BAAB,BABA\}$

So, I need to know what this $w(n)=w({n}_{i},{n}_{j})$ is. Some references on aproaches on how to solve this kind of problems and related algorithms to generate such words would be apreciated.