Given $n,d\in \mathbb{Z}^+$, how many subgroups of index $d$ does the free group of rank $n$ have?

In case $n=1$ the question is trivial, and in case $n=2, d=2$ there are 3 such subgroups. I think I have got a algorithm to solve case $d=2$ for arbitrary $n$. But the general case seems very difficult. For example in case $n=2$ and $d$ a prime number, I don't know how to proceed.

That's my question. Any suggestions will be appreciated. Thanks