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
import java.math.BigInteger;
import java.util.Scanner;

public class fib {

	class FibMod {
		
		BigInteger current = BigInteger.ONE.negate();
		
		long a = 0;
		
		long b = 1;
		
		public long next() {
			current = current.add(BigInteger.ONE);
			
			if (current.equals(BigInteger.ZERO)) {
				return 0L;
			} else if (current.equals(BigInteger.ONE)) {
				return 1L;
			} else {
				long tmp = (a + b) % 1000000000000000000L;
				a = b;
				b = tmp;
				return b;
			}			
		}
	}
	
	public void check(int n, int size) {
		FibMod fib = new FibMod();
		long mod = (long) Math.pow(10, size);
		long maxRange = 15000L;
		
		if (size >= 3) {
			maxRange = 15 * (long) Math.pow(10, size - 1) + 1;
		}
		
		for (long i=0L; i<maxRange; i++) {
			long f = fib.next();
			if (f > mod && (f - n) % mod == 0) {
				System.out.println(i);
				return;
			}
		}
		
		System.out.println("NIE");
	}
	
	public static void main(String[] args) {
		int n, size;
		
		Scanner scanner = new Scanner(System.in);
		String input = scanner.next();
		scanner.close();
		n = Integer.valueOf(input);
		size = input.length();
		
		fib f = new fib();
		f.check(n, size);
	}
	
}