Solution (source code)

= Solution

The <Nielsen–Schreier theorem> says that every <subgroup> of a <free group> is free. Realize $F_n$ as the <fundamental group> of the rose $R_n$, the graph with one vertex and $n$ oriented loops. A subgroup $H\leq F_n$ of finite <index of a subgroup> $d$ corresponds to a connected $d$-sheeted <covering graph> $X\to R_n$. The graph $X$ has $d$ vertices and $dn$ unoriented edges. Choosing a <spanning tree> leaves
$$
dn-(d-1)=1+d(n-1)
$$
edges outside the tree, and these freely generate $\pi_1(X)\cong H$. Thus the <Nielsen–Schreier formula> is
$$
\boxed{\operatorname{rank}(H)=1+d(n-1).}
$$