Finding the number of distinct permutations of length N with n different symbols
The total number of (different) permutations of strings with $n_i$ characters of type $i$ is given by
$$\frac{(\sum_i n_i)!}{\prod_i n_i!}.$$
In other words, if the length of the string is $n=n_1 + n_2 +...$, you have
$\frac{n!}{n_1!n_2!n_3!\ldots}$ different permutations.
Note that the formula fits your simple case.

Why is this formula correct?

Because $n!$ is the number of permutations. But some permutations give the same string (e.g., aa rotated is still aa). Then we need to "remove" all the permutations that give the same string. For a given string, for each letter $i$, there are $n_i$ permutations that are identical to the string we started with. So (for each possible letter $i$) we divide by this number to get the final result.