1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <string>

using namespace std;

string dodaj(string a, string b)
{
    if(b.length()>a.length()) a.insert(0, "0");
    for(int i=b.length()-1; i>=0 ; i--)
    {
        a[i]+=b[i]-48;
        if(a[i]>57)
        {
            a[i]-=10;
            if(i>0)
            {
                a[i-1]+=1;
            }
            else
            {
                a.insert(0, "1");
            }
        }
    }
    return a;
}

int main()
{
    string ko, b, a;
    cin>>ko;
    if(ko=="0") cout<<"0";
    else if(ko=="1") cout<<"1";
    a=b="1";
    int li=3;
    while(li<550)
    {
        a=dodaj(a, b);
        swap(a, b);
        if(b.length()>=ko.length())
        {
            if(ko==b.substr(b.length()-ko.length(), ko.length()))
            {
                cout<<li;
                return 0;
            }
        }
        li++;
    }
    cout<<"NIE";
    return 0;
}