Your math teacher, Agrippina Sergeevna, wrote the number $$$1$$$ on the board. The task for today's class is to obtain the number $$$N$$$ from it. Of course, your actions are limited to a certain set of possible operations. All you can do is:
Everyone wants to go home as soon as possible, so it would be nice to obtain the number $$$N$$$ with the minimum number of operations. Help the class (and yourself) by finding the minimum number of described operations required to obtain the number $$$N$$$, or determine that it is impossible, in which case everyone will have to stay until the end of the class.
The input consists of a single line containing an integer $$$N$$$ that needs to be obtained ($$$1 \leqslant N \leqslant 9999$$$).
Output a single integer — the minimum number of operations required to obtain $$$N$$$, or "-1" if it is impossible.
4
2
61
5
3
-1
In the first example, the following sequence of actions will work: $$$1 \to 2 \to 4$$$.
In the second example, you can proceed as follows: $$$1 \to 2 \to 4 \to 8 \to 16 \to 61$$$.