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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

string suma( string a, string b )
{
    string c;
    int j = b.size() - 1;
    int l = 0;
    if( a.size() < b.size() )
    {
        string x = a;
        a = b;
        b = x;
    }
    //cout << a << " " << b << "\n";
    string g;
    for( int i = 0; i < a.size() - b.size(); i ++ )
    {
        g.push_back('0');
    }
    if( a.size() != b.size() ) b = g + b;
    //cout << g << "\n";
    for( int i = a.size() - 1; i >= 0; i -- )
    {
        int r = a[i] + b[i] - '0' - '0' + l;
        //if( a == "13" ) cout << r << " ";
        if( r < 10 )
        {
            char p = r + '0';
            c.push_back(p);
            l = 0;
        }
        else
        {
            char p = r%10 + '0';
            c.push_back(p);
            l = r/10;
        }
    }
    //cout << c << "\n";
    if( l > 0 )
    {
        char p = l + '0';
        c.push_back(p);
    }
    reverse(c.begin(),c.end());
    return c;
}

int check( string a, string b )
{
    bool flag = true;
    int j = b.size() - 1;
    for( int i = a.size() - 1; i >= 0; i -- )
    {
        if( a[i] != b[j] )
        {
            //cout << a[i] << " " << b[j] << "\n";
            flag = false;
            break;
        }
        j --;
        //if( j == -1 ) break;
    }
    return flag;
}

int main()
{
    ios_base::sync_with_stdio(0);
    string n;
    cin >> n;
    string a = "0", b = "1";
    if( check(n,a) == true ) { cout << 0 << "\n"; return 0; }
    else if( check(n,b) == true ) { cout << 1 << "\n"; return 0; }
    for( int i = 0; i < 10000; i ++ )
    {
        string d = suma(a,b);
        a = b;
        b = d;
        //cout << d << "\n";
        if( check(n,b) == true )
        {
            cout << i + 2 << "\n";
            //cout << b << "\n";
            return 0;
        }
        //cout << b << "\n";
    }
    cout << "NIE\n";
    return 0;
}