#P5580. [PA 2015] Fibonacci

[PA 2015] Fibonacci

Description

As everyone knows, the Fibonacci sequence FF satisfies:

F0=0,F1=1,Fm=Fm1+Fm2(2m)F_0=0,F_1=1,F_m=F_{m-1}+F_{m-2}(2\le m)

Now you are given a digit string SS. Please find the smallest kk such that FkF_k ends with SS.

Input Format

One line containing a digit string SS.

Output Format

Output the smallest integer kk that satisfies the condition.

If there is no solution, output NIE.

025
1525

Hint

Constraints: for 100%100\% of the testdata, the length of SS is at most 1818, and 0k<101000\le k<10^{100}.

Translated by ChatGPT 5