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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

ULL policz(string l0){
	ULL liczba = 0;
	for(int i = 0; i < l0.length(); ++i)
		liczba = liczba*10 + l0[i] -'0';
	return liczba;
}

int main(){
	const int MAX = 10000000;
	int k;
	string liczba0;
	cin >> liczba0;
	ULL liczba = policz(liczba0);
	int ile0 = liczba0.length();
	ULL ile = 1;
	while(ile0--) ile *= 10;
	//cout << ile << ' ' << liczba << endl;
	ULL fib0 = 0, fib1 = 1;
	//while (fib1 % ile != liczba){
	for(k = 2; k < MAX; ++k){
		ULL tmp = fib0 + fib1;
		fib0 = fib1;
		fib1 = tmp % ile;
		if(fib1 == liczba) /*cout << k << endl;*/break;
	}
	if (k < MAX)
			cout /*<< fib1 << ' ' */<< k << endl;
	else cout << "NIE\n";
}