#include<iostream>
#include<cstdint>
using namespace std;

long long modulos[20];
long long cycles[20];
long long suffix[20];

// MNOŻENIE LICZB <10^18 MODULO 10^18
long long multiply(long long a, long long b){
	// mnożymy po kolei  b%10^n * n-ta cyfra a od końca.
	// W ten sposób maksymalnym mnożeniem będzie 999'999'999'999'999'999 * 9
	// TA-DAAA
	unsigned long long main_mod = modulos[18];
	unsigned long long b_mod = main_mod;
	unsigned long long current_mult = 1ULL;
	unsigned long long _first;
	unsigned long long result = 0ULL;
	
	while(a > 0){
		_first = a % 10ULL;
		a /= 10ULL;
		_first *= current_mult;
		current_mult *= 10ULL;
		
		b %= b_mod;
		b_mod /= 10ULL;
		
		result += _first * b;
		result %= main_mod;
	}
	
	return (long long)result;
}

struct fib{
	long long matr[2][2];
	long long num;
	
	fib(){}
	
	fib(long long f2, long long f1, long long fn, long long num)
	: num(num) {
		matr[0][0] = f2;
		matr[0][1] = f1;
		matr[1][0] = f1;
		matr[1][1] = fn;
	}
	
	long long value() const{
		// returns num-th fibonacci number.
		return matr[1][0];
	}
	
	void mult(fib& b){
		// mnożenie macierzy przez macierz
		long long temp1 = multiply(matr[0][0], b.matr[0][0]) + multiply(matr[0][1], b.matr[1][0]);
		long long temp2 = multiply(matr[0][0], b.matr[0][1]) + multiply(matr[0][1], b.matr[1][1]);
		temp1 %= modulos[18];
		temp2 %= modulos[18];
		
		matr[0][0] = temp1;
		matr[0][1] = temp2;
		matr[1][0] = temp2;
		matr[1][1] = (temp1 + temp2) % modulos[18];
		
		num += b.num;
		num %= (modulos[18] * 4LL);
	}
};

long long n, k, result, nlength;

// matrix used to go cycle[i] fibonnaci numbers ahead
fib cycle_matrix[20];


void check(fib number, int length){
	//cout << "Checking " << number.num << ": " << number.value() << "  at length " << length << " for " << n << endl;
	// number - number we are checking
	// length - current length of suffix
	if(length == nlength){
		if(number.value() % modulos[length] == n){
			// if the number matches, that's it.
			result = number.num;	
			result += cycles[18];
			cout << result << endl;
			exit(0);
		}
	}else{
		for(int i = 0; i <= 9; ++i){
			if(number.value() % modulos[length] == n % modulos[length]){
				check(number, length + 1);
				// matches, go deeper
			}
			number.mult(cycle_matrix[length]);
		}
	}	
}

void makecyclemtx(){
	cycle_matrix[0] = fib(0LL, 1LL, 1LL, 1LL);
	cycle_matrix[1] = fib(956722026041LL, 1548008755920LL, 2504730781961LL, 60LL);
	cycle_matrix[2] = fib(212767467264610201LL, 96499764990979600LL, 309267232255589801LL, 300LL);
	cycle_matrix[3] = fib(827073452325051001LL, 187122583354898000LL, 14196035679949001LL, 1500LL);
	cycle_matrix[4] = fib(245798558475510001LL, 655976683548980000LL, 901775242024490001LL, 15000LL);
	cycle_matrix[5] = fib(98381607255100001LL, 810616835489800000LL, 908998442744900001LL, 150000LL);
	cycle_matrix[6] = fib(890918322551000001LL, 956168354898000000LL, 847086677449000001LL, 1500000LL);
	cycle_matrix[7] = fib(119408225510000001LL, 561683548980000000LL, 681091774490000001LL, 15000000LL);
	cycle_matrix[8] = fib(216582255100000001LL, 616835489800000000LL, 833417744900000001LL, 150000000LL);
	cycle_matrix[9] = fib(415822551000000001LL, 168354898000000000LL, 584177449000000001LL, 1500000000LL);
	cycle_matrix[10] = fib(158225510000000001LL, 683548980000000000LL, 841774490000000001LL, 15000000000LL);
	cycle_matrix[11] = fib(582255100000000001LL, 835489800000000000LL, 417744900000000001LL, 150000000000LL);
	cycle_matrix[12] = fib(822551000000000001LL, 354898000000000000LL, 177449000000000001LL, 1500000000000LL);
	cycle_matrix[13] = fib(225510000000000001LL, 548980000000000000LL, 774490000000000001LL, 15000000000000LL);
	cycle_matrix[14] = fib(255100000000000001LL, 489800000000000000LL, 744900000000000001LL, 150000000000000LL);
	cycle_matrix[15] = fib(551000000000000001LL, 898000000000000000LL, 449000000000000001LL, 1500000000000000LL);
	cycle_matrix[16] = fib(510000000000000001LL, 980000000000000000LL, 490000000000000001LL, 15000000000000000LL);
	cycle_matrix[17] = fib(100000000000000001LL, 800000000000000000LL, 900000000000000001LL, 150000000000000000LL);
	cycle_matrix[18] = fib(1LL, 0LL, 1LL, 1500000000000000000LL);
}

string s;
int main(){	
	cin >> s;
	
	nlength = s.length();
	long long tenpower = 1;	
	for(int i = nlength - 1; i >= 0; --i){
		n += (long long)(s[i] - 48) * tenpower;
		tenpower *= 10LL;
	}
	
	modulos[0] = 1LL;
	for(int i = 1; i < 19; ++i){
		modulos[i] = modulos[i - 1] * 10LL;
		suffix[i] = n % modulos[i];
	}
	cycles[0] = 1LL;
	cycles[1] = 60LL;
	cycles[2] = 300LL;
	cycles[3] = 1500LL;
	for(int i = 4; i < 19; ++i){
		cycles[i] = cycles[i - 1] * 10LL;
	}
	
	makecyclemtx();
	
	// ZNAJDUJEMY KOŃCÓWKI 6-CYFROWE BRUTEM I PUSZCZAMY OD NICH MAGICZNEGO DFS-A
	result = -1LL;
	long long first6 = n % modulos[6];
	long long f2 = 0LL;
	long long f1 = 1LL;
	long long fnm6 = 0LL;
	if(nlength <= 6){
		for(long long i = 2LL; i < cycles[6]; ++i){
			long long fn = (f1 + f2) % modulos[nlength];
			f2 = f1;
			f1 = fn;
			if(fn == first6){
				result = i;
				break;
			}
		}
	}else{
		// CHECK 0/1 HERE JUST IN CASE?
		// [will see after testing]
		// maybe multiplied by 1.5 * 10^18 to get the same results mod 10^18
		//  fix: +3 should do the trick. I think.
		for(long long i = 2LL; i < cycles[6] + 3; ++i){
			long long fn = (f1 + f2) % modulos[18];
			f2 = f1;
			f1 = fn;
			fnm6 = fn % modulos[6];
			if(fnm6 == first6){
				// PUSZCZAMY DFS
				fib newfib(f2, f1, fn, i);
				check(newfib, 6);
			}
		}
	}
	
	if(result == -1LL){
		cout << "NIE" << endl;
	}else{	
		result += cycles[18];
		cout << result << endl;
	}
	

	return 0;
}
