Let $P(x)=x^2 -1$. Find out number of distinct real roots of $P(P(\cdots P(x))\cdots)=0$ where there are $2018$ $P$. Let $P(x)=x^2 -1$. Find out number of distinct real roots of $P(P(\cdots P(x))\cdots)=0$ where there are $2018$ $P$.
My Attempt
Let $Q(x)=P(P(\cdots P(x))\cdots)=0$ where there are $2017$ $P$ is a root of $P(x)=0$. Thus $Q(x)=\pm1$. But from this point I am lost how to proceed. Can anyone help. Thanks in advance.

Let $a_n$ be the number of roots of the equation with $n P$'s.
Now we have $a_1= 2$. and $a_2 =3$.
For simplicity, denote $P_n$ with the equation of $n P$'s.
For $n \ge 2$, we have : $$ P_n^2 -1 = ((P_{n-2}^2-1)^2-1)^2 -1 = (P_{n-2}^2 -1)^2((P_{n-2}^2-1) -\sqrt{2})((P_{n-2}^2-1) + \sqrt{2}).  $$ (Here $P_0(x) =x$).
Now the first factor has roots $a_{n-2}$. The third factor has no roots. We show that the second factor has 2 roots. 
Let $g_n(x)= P_{n-2}^2 - (\sqrt{2}+1)$.We claim that the roots are  $$\pm \sqrt{\sqrt{\sqrt{\cdots \sqrt{\sqrt{2}+1~ (\text{n -1 times})}\cdots +1}+1}+1} .$$
This can be verified by factorizing and seeing that we have a expression of form $(g^2-1)^2 - b$ where $b>1$, then only the factor $g^2 - (\sqrt{b}+1)$ can only real root in the factorization of the expression.
Thus we have $a_n = a_{n-2}+2$. Thus the sequence is natural numbers. So the answer shall be then $2017$.
