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
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;

const lli MOD2 = 1e9;
const lli MOD = 1e18;

lli pot[19] = {1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18};

int main()
{
    char s[19];

    scanf("%s", s);

    string in_num = s, num = "";

    if(in_num == "0")
    {
        printf("0");
        return 0;
    }
    if(in_num == "1")
    {
        printf("1");
        return 0;
    }

    int ind = 0;

    while(in_num[ind] == '0')
    {
        ++ind;
    }

    while(ind < in_num.length())
    {
        num += in_num[ind];
        ++ind;
    }

    lli num_conver = 0;

    ind = 0;

    while(ind < num.length())
    {
        num_conver *= 10;
        num_conver += (int)(num[ind] - '0');
        ++ind;
    }

    lli a_0 = 0, a_1 = 1, a_2, a_temp;

    for(lli i = 2; i < 10000000; ++i)
    {
        a_2 = (a_0 + a_1) % MOD;
        a_0 = a_1;
        a_1 = a_2;
        a_temp = a_2 % (pot[num.length()]);

        if(a_temp == num_conver)
        {
            printf("%lld", i);
            return 0;
        }
    }

    printf("NIE");

    return 0;
}