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
#include <iostream>

using namespace std;
typedef unsigned long long ull;


ull lim = 1000000000000000000; 
ull c;

int main()
{
	ios_base::sync_with_stdio(false);
	
	ull n;
	cin >> n;

	if(n % 8 == 6 || n % 8 == 4)
	{
		cout << "NIE" << endl;
		return 0;
	}

	
	//cout << "==== " << n << endl;
	
	ull len = 0;
	ull pom = n;
	ull mod = 1;
	while( pom > 0 )
	{
		len++;
		pom /= 10;
		mod *= 10;
	}


	ull f0 = 0;
	ull f1 = 1;
	ull f2 = 2;
	ull k = 2;
	if( f0 % mod == n)
	{
		cout << f0 << endl;
		return 0;
	}

	while( k <= 1000000 )
	{
		f2 = f1 + f0;
		f0 = f1;
		f1 = f2;
		
		if( f2 % mod == n)
		{
			cout << k << endl;
			return 0;
		}
		k++;

		if(f2 >= lim)
		{
			c++;
			f0 %= lim;
			f1 %= lim;
			f2 %= lim;
		}
	}

	cout << "NIE" << endl;
	
	



	return 0;
}