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
#include <cstdio>
#include <string>
#include <math.h> 

using namespace std;

int fib(long long int n,  int seq) {
    if ( n == 0 || n == 1 ) 
        return n;
 
    int fib1 = 0; 
    int fib2 = 1;
    int fib = 0;
    int number = seq;
    long long max;	

    int x  = 0; while (number != 0) { number /= 10; x++; }
    
    max = 15 * pow(10,x-1);
    x = pow(10, x);

   for ( long long int i = 2; i < max; i++ ) 
    {
        fib = (fib1 + fib2) % x;
	
		fib1 = fib2;
		fib2 = fib;
	
	if(seq == fib){
		printf("%lld",i);
		return fib;
	}
    }
    printf("NIE");
    return fib;
}

int main(){
	
	long long int x= 1000000000000000000;
	int seq;

	scanf("%d", &seq);
	
	fib(x, seq);

}