Let
\[f_1(x) = \frac{1}{x}\quad\text{and}\quad f_2(x) = 1 - x\]
Let $H$ be the set of all compositions of the form $h_1 \circ h_2 \circ \ldots \circ h_k$, where each $h_i$ is either $f_1$ or $f_2$.  For all $h$ in $H$, let $h^{(n)}$ denote $h$ composed with itself $n$ times.  Find the greatest integer $N$ such that $\pi, h(\pi), \ldots, h^{(N)}(\pi)$ are all distinct for some $h$ in $H$.

Let's think step by step and output the final answer within \boxed{}.
user