John Doe has a list of all Fibonacci numbers modulo 1013. This list is infinite, it starts with numbers 0 and 1. Each number in the list, apart from the first two, is a sum of previous two modulo 1013. That is, John's list is made from the Fibonacci numbers' list by replacing each number there by the remainder when divided by 1013. John got interested in number f (0 ≤ f < 1013) and now wants to find its first occurrence in the list given above. Help John and find the number of the first occurence of number f in the list or otherwise state that number f does not occur in the list. The numeration in John's list starts from zero. There, the 0-th position is the number 0, the 1-st position is the number 1, the 2-nd position is the number 1, the 3-rd position is the number 2, the 4-th position is the number 3 and so on. Thus, the beginning of the list looks like this: 0, 1, 1, 2, 3, 5, 8, 13, 21, ...

The first line contains the single integer f (0 ≤ f < 1013) — the number, which position in the list we should find. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Print a single number — the number of the first occurrence of the given number in John's list. If this number doesn't occur in John's list, print -1.

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	final static int PERIOD = 60;
	final static int POWER = 13;

	long fib(long n, long mod) {
		long[][] mat = new long[2][2];
		mat[0][1] = mat[1][0] = mat[1][1] = 1;
		Matrix v = new Matrix(mat);
		v = v.power(n, mod);
		return v.mat[0][1];
	}

	void run() {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);

		long num = in.nextLong(), mod = 10, per = PERIOD;
		ArrayList<Long> valid = new ArrayList<Long>();
		for (int i = 0; i < PERIOD; ++i)
			if (fib(i, mod) == num % mod)
				valid.add((long)i);

		for (int i = 1; i < POWER; ++i) {
			mod *= 10;
			long rem = num % mod;
			ArrayList<Long> nv = new ArrayList<Long>();
			for (int j = 0; j < 10; ++j)
				for (int k = 0; k < valid.size(); ++k) {
					if (fib(j * per + valid.get(k), mod) == rem)
						nv.add(j * per + valid.get(k));
				}
			valid = nv;
			per *= 10;
		}

		if (valid.size() == 0)
			out.println(-1);
		else
			out.println(valid.get(0));
		out.close();
	}
}

class Matrix {
	long[][] mat;
	final static Matrix ONE = new Matrix(new long[][] {{1, 0}, {0, 1}});
	Matrix(long[][] mat) {
		this.mat = mat;
	}
	long add(long a, long b, long mod) {
		if (a + b >= mod)
			return a + b - mod;
		return a + b;
	}
	long multiply(long a, long b, long mod) {
		long ret = 0;
		while (a > 0) {
			if ((a & 1) == 1)
				ret = add(ret, b, mod);
			b = add(b, b, mod);
			a >>= 1;
		}
		return ret;
	}
	Matrix multiply(Matrix o, long mod) {
		long[][] ret = new long[2][2];
		for (int i = 0; i < 2; ++i)
			for (int j = 0; j < 2; ++j)
				for (int k = 0; k < 2; ++k)
					ret[i][j] = add(ret[i][j], multiply(mat[i][k], o.mat[k][j], mod), mod);
		return new Matrix(ret);
	}
	Matrix power(long p, long mod) {
		if (p == 0) {
			return Matrix.ONE;
		}
		Matrix ret = power(p / 2, mod);
		ret = ret.multiply(ret, mod);
		if ((p & 1) == 1)
			ret = ret.multiply(this, mod);
		return ret;
	}
}

class InputReader {
	BufferedReader buff;
	StringTokenizer tokenizer;

	InputReader(InputStream stream) {
		buff = new BufferedReader(new InputStreamReader(stream));
		tokenizer = null;
	}
	boolean hasNext() {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			try {
				tokenizer = new StringTokenizer(buff.readLine());
			}
			catch (Exception e) {
				return false;
			}
		return true;
	}
	String next() {
		if (!hasNext())
			throw new RuntimeException();
		return tokenizer.nextToken();
	}
	int nextInt() { return Integer.parseInt(next()); }
	long nextLong() { return Long.parseLong(next()); }
}

//package round122;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class E2 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int M2 = 1<<13;
		int M5 = 5*5*5*5*5*5*5*5*5*5*5*5*5;

		long f = nl();
		int x2 = (int)(f % M2);
		int[] fa2 = new int[M2];
		int[] a2 = new int[1<<14];
		a2[0] = 0;
		a2[1] = 1;
		Arrays.fill(fa2, -1);
		fa2[0] = 0;
		fa2[1] = 1;
		for(int i = 2;i < 13000;i++){
			a2[i] = (a2[i-1] + a2[i-2]) % M2;
			if(fa2[a2[i]] == -1)fa2[a2[i]] = i;
		}
		if(fa2[x2] == -1){
			out.println(-1);
			return;
		}

		int f5 = (int)(f%5);
		List<Long> l = new ArrayList<Long>();
		{
			int[] a = new int[20];
			a[0] = 0;
			a[1] = 1;
			for(int i = 2;i < 4*5;i++){
				a[i] = (a[i-1] + a[i-2]) % 5;
			}
			for(int i = 0;i < 4*5;i++){
				if(a[i] == f5){
					l.add((long)i);
				}
			}
		}

		int[][] F = {
				{1, 1}, {1, 0}
		};
		for(long m = 25;m <= M5;m*=5){
			int fm = (int)(f % m);
			List<Long> nl = new ArrayList<Long>();
			for(long ll : l){
				for(int k = 0;k < 5;k++){
					long ne = ll+k*4*(m/5);
					long nf = 0;
					if(ne == 0){
						nf = 0;
					}else{
						nf = pow(F, new int[]{1, 0}, ne-1, (int)m)[0];
					}
					if(nf == fm){
						nl.add(ne);
					}
				}
			}
			l = nl;
		}

		long min = Long.MAX_VALUE;
		for(long ll : l){
			for(int i = 0;i < a2.length;i++){
				if(a2[i] == f % M2){
					long num = crtx(new long[]{M2*3/2, 4L*M5}, new long[]{i, ll}).longValue();
					if(num >= 0){
						min = Math.min(min, num);
					}
				}
			}
//			long num = crt(M2*3/2, fa2[x2], 4L*M5, ll);
		}
		if(min == Long.MAX_VALUE){
			out.println(-1);
		}else{
			out.println(min);
		}
	}

	public static long crt(long p, long m, long q, long n)
	{
		long[] apr = exGCD(p, q);
		if((n - m) % apr[0] != 0)return -1;
		long mod = p * q / apr[0];
		long a = (apr[1] * (n - m) / apr[0] * p + m) % mod;
		if(a < 0)a += mod;
		return a;
	}

	// int行列*ベクトル
	public static int[] mul(int[][] A, int[] v, int mod)
	{
		int m = A.length;
		int n = v.length;
		int[] w = new int[m];
		for(int i = 0;i < m;i++){
			long sum = 0;
			for(int k = 0;k < n;k++){
				sum += (long)A[i][k] * v[k];
				sum %= mod;
			}
			w[i] = (int)sum;
		}
		return w;
	}

	// int行列の2乗
	public static int[][] p2(int[][] A, int mod)
	{
		int n = A.length;
		int[][] C = new int[n][n];
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				long sum = 0;
				for(int k = 0;k < n;k++){
					sum += (long)A[i][k] * A[k][j];
					sum %= mod;
				}
				C[i][j] = (int)sum;
			}
		}
		return C;
	}

	public static BigInteger[] exGCD(BigInteger a, BigInteger b)
	{
		BigInteger p = BigInteger.ONE, q = BigInteger.ZERO, r = BigInteger.ZERO, s = BigInteger.ONE;
		while(b.signum() > 0){
			BigInteger c = a.divide(b);
			BigInteger d;
			d = a; a = b; b = d.mod(b);
			d = p; p = q; q = d.subtract(c.multiply(q));
			d = r; r = s; s = d.subtract(c.multiply(s));
		}
		return new BigInteger[]{a, p, r};
	}

	public static BigInteger bi(long x){ return BigInteger.valueOf(x); }

	public static BigInteger crtx(long[] divs, long[] mods)
	{
		BigInteger div = bi(divs[0]), mod = bi(mods[0]);
		for(int i = 1;i < divs.length;i++){
			BigInteger[] apr = exGCD(div, bi(divs[i]));
			BigInteger mm = bi(mods[i]).subtract(mod);
			if(mm.mod(apr[0]).signum() != 0)return bi(-1);
			BigInteger da = div.divide(apr[0]);
			BigInteger ndiv = bi(divs[i]).multiply(da);
			BigInteger nmod = apr[1].multiply(mm).multiply(da).add(mod).mod(ndiv);
			if(nmod.signum() < 0)nmod = nmod.add(ndiv);
			div = ndiv;
			mod = nmod;
		}
		return mod;
	}

	// A^e*v
	public static int[] pow(int[][] A, int[] v, long e, int mod)
	{
		int[][] MUL = A;
		for(;e > 0;e>>>=1) {
			if((e&1)==1)v = mul(MUL, v, mod);
			MUL = p2(MUL, mod);
		}
		return v;
	}

	public static long[] exGCD(long a, long b)
	{
		long p = 1, q = 0, r = 0, s = 1;
		while(b > 0){
			long c = a / b;
			long d;
			d = a; a = b; b = d % b;
			d = p; p = q; q = d - c * q;
			d = r; r = s; s = d - c * s;
		}
		return new long[]{a, p, r};
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new E2().run();
	}

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

import java.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE {
    static final long MODULO = (long) 1e13;

    private long[][] mul(long[][] a, long[][] b, long modulo) {
        long[][] c = new long[2][2];
        for (int i = 0; i < 2; ++i)
            for (int j = 0; j < 2; ++j) {
                BigInteger sum = BigInteger.ZERO;
                for (int k = 0; k < 2; ++k)
                    sum = sum.add(BigInteger.valueOf(a[i][k]).multiply(BigInteger.valueOf(b[k][j])));
                c[i][j] = sum.mod(BigInteger.valueOf(modulo)).longValue();
            }
        return c;
    }

    static class Candidate {
        long offset;
        long[][] trans;

        Candidate(long offset, long[][] trans) {
            this.offset = offset;
            this.trans = trans;
        }
    }

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        long f = in.nextLong();
        long mod = 1;
        long period = 1;
        long[][] mPeriod = new long[][]{new long[]{0, 1}, new long[]{1, 1}};
        List<Candidate> offsets = new ArrayList<Candidate>();
        offsets.add(new Candidate(0, new long[][]{new long[]{1, 0}, new long[]{0, 1}}));
        for (int i = 0; i < 26; ++i) {
            if (i < 13)
                mod *= 2;
            else
                mod *= 5;
            long nperiod = period;
            long[][] nmPeriod = mPeriod;
            while (nmPeriod[0][1] % mod != 0 || nmPeriod[1][1] % mod != 1) {
                nmPeriod = mul(nmPeriod, mPeriod, MODULO);
                nperiod += period;
            }
            List<Candidate> newOffsets = new ArrayList<Candidate>();
            for (Candidate old : offsets) {
                long[][] trans = old.trans;
                for (long noffset = old.offset; noffset < nperiod; noffset += period) {
                    if ((trans[0][1] % mod == f % mod)) {
                        newOffsets.add(new Candidate(noffset, trans));
                    }
                    trans = mul(trans, mPeriod, MODULO);
                }
            }
            offsets = newOffsets;
            period = nperiod;
            mPeriod = nmPeriod;
        }
        long min = Long.MAX_VALUE;
        for (Candidate c : offsets)
            min = Math.min(min, c.offset);
        if (min == Long.MAX_VALUE) out.println(-1); else out.println(min);
	}
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    }

import java.io.*;
import java.math.*;
import java.util.*;

public class Solution {
    final static long MOD = 10000000000000L;

    long multiply(long a, long b) {
        return BigInteger.valueOf(a).multiply(BigInteger.valueOf(b)).remainder(BigInteger.valueOf(MOD)).longValue();
    }

    long[][] multiply(long[][] a, long[][] b) {
        long[][] c = new long[2][2];
        for (int i = 0; i < 2; ++ i) {
            for (int j = 0; j < 2; ++ j) {
                c[i][j] = (multiply(a[i][0], b[0][j]) + multiply(a[i][1], b[1][j])) % MOD;
            }
        }
        return c;
    }

    long[][] pow(long[][] a, long n) {
        long[][] ret = new long[][] {{1, 0}, {0, 1}};
        while (n > 0) {
            if (n % 2 == 1) {
                ret = multiply(ret, a);
            }
            a = multiply(a, a);
            n >>= 1;
        }
        return ret;
    }

    long fibonacci(long n) {
        return multiply(new long[][] {{0, 1}, {0, 0}}, pow(new long[][]{{0, 1}, {1, 1}}, n))[0][0];
    }

    public void run() {
        try {
            long m = reader.nextLong();
            ArrayList <Long> indices = new ArrayList <Long>();
            indices.add(0L);
            long period = 1;
            for (long mod = 10; mod <= MOD; mod *= 10) {
                ArrayList <Long> newIndices = new ArrayList <Long>();
                int times = mod == 10 ? 60 : mod <= 1000 ? 5 : 10;
                for (long iter : indices) {
                    long now = iter;
                    for (int i = 0; i < times; ++ i) {
                        if (fibonacci(now) % mod == m % mod) {
                            newIndices.add(now);
                        }
                        now += period;
                    }
                }
                period *= times;
                indices = newIndices;
            }
            Collections.sort(indices);
            writer.println(indices.isEmpty() ? -1 : indices.get(0));
        } catch (IOException ex) {
        }
        writer.close();
    }

    InputReader reader;
    PrintWriter writer;

    Solution() {
        reader = new InputReader();
        writer = new PrintWriter(System.out);
    }

    public static void main(String[] args) {
        new Solution().run();
    }

}

class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    InputReader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    Integer nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    Long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}

//package round122;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class E2 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int M2 = 1<<13;
		int M5 = 5*5*5*5*5*5*5*5*5*5*5*5*5;

		long f = nl();
		int x2 = (int)(f % M2);
		int[] fa2 = new int[M2];
		{
			int[] a = new int[1<<14];
			a[0] = 0;
			a[1] = 1;
			Arrays.fill(fa2, -1);
			fa2[0] = 0;
			fa2[1] = 1;
			for(int i = 2;i < 13000;i++){
				a[i] = (a[i-1] + a[i-2]) % M2;
				if(fa2[a[i]] == -1)fa2[a[i]] = i;
			}
			if(fa2[x2] == -1){
				out.println(-1);
				return;
			}
		}

		int f5 = (int)(f%5);
		List<Long> l = new ArrayList<Long>();
		{
			int[] a = new int[20];
			a[0] = 0;
			a[1] = 1;
			for(int i = 2;i < 4*5;i++){
				a[i] = (a[i-1] + a[i-2]) % 5;
			}
			for(int i = 0;i < 4*5;i++){
				if(a[i] == f5){
					l.add((long)i);
				}
			}
		}

		int[][] F = {
				{1, 1}, {1, 0}
		};
		for(long m = 25;m <= M5;m*=5){
			int fm = (int)(f % m);
			List<Long> nl = new ArrayList<Long>();
			for(long ll : l){
				for(int k = 0;k < 5;k++){
					long ne = ll+k*4*(m/5);
					long nf = 0;
					if(ne == 0){
						nf = 0;
					}else{
						nf = pow(F, new int[]{1, 0}, ne-1, (int)m)[0];
					}
					if(nf == fm){
						nl.add(ne);
					}
				}
			}
			l = nl;
		}

		long min = Long.MAX_VALUE;
		for(long ll : l){
			long num = crtx(new long[]{M2*3/2, 4L*M5}, new long[]{fa2[x2], ll}).longValue();
//			long num = crt(M2*3/2, fa2[x2], 4L*M5, ll);
			if(num >= 0){
				min = Math.min(min, num);
			}
		}
		if(min == Long.MAX_VALUE){
			out.println(-1);
		}else{
			out.println(min);
		}
	}

	public static long crt(long p, long m, long q, long n)
	{
		long[] apr = exGCD(p, q);
		if((n - m) % apr[0] != 0)return -1;
		long mod = p * q / apr[0];
		long a = (apr[1] * (n - m) / apr[0] * p + m) % mod;
		if(a < 0)a += mod;
		return a;
	}

	// int行列*ベクトル
	public static int[] mul(int[][] A, int[] v, int mod)
	{
		int m = A.length;
		int n = v.length;
		int[] w = new int[m];
		for(int i = 0;i < m;i++){
			long sum = 0;
			for(int k = 0;k < n;k++){
				sum += (long)A[i][k] * v[k];
				sum %= mod;
			}
			w[i] = (int)sum;
		}
		return w;
	}

	// int行列の2乗
	public static int[][] p2(int[][] A, int mod)
	{
		int n = A.length;
		int[][] C = new int[n][n];
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				long sum = 0;
				for(int k = 0;k < n;k++){
					sum += (long)A[i][k] * A[k][j];
					sum %= mod;
				}
				C[i][j] = (int)sum;
			}
		}
		return C;
	}

	public static BigInteger[] exGCD(BigInteger a, BigInteger b)
	{
		BigInteger p = BigInteger.ONE, q = BigInteger.ZERO, r = BigInteger.ZERO, s = BigInteger.ONE;
		while(b.signum() > 0){
			BigInteger c = a.divide(b);
			BigInteger d;
			d = a; a = b; b = d.mod(b);
			d = p; p = q; q = d.subtract(c.multiply(q));
			d = r; r = s; s = d.subtract(c.multiply(s));
		}
		return new BigInteger[]{a, p, r};
	}

	public static BigInteger bi(long x){ return BigInteger.valueOf(x); }

	public static BigInteger crtx(long[] divs, long[] mods)
	{
		BigInteger div = bi(divs[0]), mod = bi(mods[0]);
		for(int i = 1;i < divs.length;i++){
			BigInteger[] apr = exGCD(div, bi(divs[i]));
			BigInteger mm = bi(mods[i]).subtract(mod);
			if(mm.mod(apr[0]).signum() != 0)return bi(-1);
			BigInteger da = div.divide(apr[0]);
			BigInteger ndiv = bi(divs[i]).multiply(da);
			BigInteger nmod = apr[1].multiply(mm).multiply(da).add(mod).mod(ndiv);
			if(nmod.signum() < 0)nmod = nmod.add(ndiv);
			div = ndiv;
			mod = nmod;
		}
		return mod;
	}

	// A^e*v
	public static int[] pow(int[][] A, int[] v, long e, int mod)
	{
		int[][] MUL = A;
		for(;e > 0;e>>>=1) {
			if((e&1)==1)v = mul(MUL, v, mod);
			MUL = p2(MUL, mod);
		}
		return v;
	}

	public static long[] exGCD(long a, long b)
	{
		long p = 1, q = 0, r = 0, s = 1;
		while(b > 0){
			long c = a / b;
			long d;
			d = a; a = b; b = d % b;
			d = p; p = q; q = d - c * q;
			d = r; r = s; s = d - c * s;
		}
		return new long[]{a, p, r};
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new E2().run();
	}

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

//package round122;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class E2 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int M2 = 1<<13;
		int M5 = 5*5*5*5*5*5*5*5*5*5*5*5*5;

		long f = nl();
		int x2 = (int)(f % M2);
		int[] fa2 = new int[M2];
		int[] a2 = new int[1<<14];
		a2[0] = 0;
		a2[1] = 1;
		Arrays.fill(fa2, -1);
		fa2[0] = 0;
		fa2[1] = 1;
		for(int i = 2;i < 13000;i++){
			a2[i] = (a2[i-1] + a2[i-2]) % M2;
			if(fa2[a2[i]] == -1)fa2[a2[i]] = i;
		}
		if(fa2[x2] == -1){
			out.println(-1);
			return;
		}

		int f5 = (int)(f%5);
		List<Long> l = new ArrayList<Long>();
		{
			int[] a = new int[20];
			a[0] = 0;
			a[1] = 1;
			for(int i = 2;i < 4*5;i++){
				a[i] = (a[i-1] + a[i-2]) % 5;
			}
			for(int i = 0;i < 4*5;i++){
				if(a[i] == f5){
					l.add((long)i);
				}
			}
		}

		int[][] F = {
				{1, 1}, {1, 0}
		};
		for(long m = 25;m <= M5;m*=5){
			int fm = (int)(f % m);
			List<Long> nl = new ArrayList<Long>();
			for(long ll : l){
				for(int k = 0;k < 5;k++){
					long ne = ll+k*4*(m/5);
					long nf = 0;
					if(ne == 0){
						nf = 0;
					}else{
						nf = pow(F, new int[]{1, 0}, ne-1, (int)m)[0];
					}
					if(nf == fm){
						nl.add(ne);
					}
				}
			}
			l = nl;
		}

		long min = Long.MAX_VALUE;
		for(long ll : l){
			for(int u : a2){
				if(u == f % M2){
					long num = crtx(new long[]{M2*3/2, 4L*M5}, new long[]{u, ll}).longValue();
					if(num >= 0){
						min = Math.min(min, num);
					}
				}
			}
//			long num = crt(M2*3/2, fa2[x2], 4L*M5, ll);
		}
		if(min == Long.MAX_VALUE){
			out.println(-1);
		}else{
			out.println(min);
		}
	}

	public static long crt(long p, long m, long q, long n)
	{
		long[] apr = exGCD(p, q);
		if((n - m) % apr[0] != 0)return -1;
		long mod = p * q / apr[0];
		long a = (apr[1] * (n - m) / apr[0] * p + m) % mod;
		if(a < 0)a += mod;
		return a;
	}

	// int行列*ベクトル
	public static int[] mul(int[][] A, int[] v, int mod)
	{
		int m = A.length;
		int n = v.length;
		int[] w = new int[m];
		for(int i = 0;i < m;i++){
			long sum = 0;
			for(int k = 0;k < n;k++){
				sum += (long)A[i][k] * v[k];
				sum %= mod;
			}
			w[i] = (int)sum;
		}
		return w;
	}

	// int行列の2乗
	public static int[][] p2(int[][] A, int mod)
	{
		int n = A.length;
		int[][] C = new int[n][n];
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				long sum = 0;
				for(int k = 0;k < n;k++){
					sum += (long)A[i][k] * A[k][j];
					sum %= mod;
				}
				C[i][j] = (int)sum;
			}
		}
		return C;
	}

	public static BigInteger[] exGCD(BigInteger a, BigInteger b)
	{
		BigInteger p = BigInteger.ONE, q = BigInteger.ZERO, r = BigInteger.ZERO, s = BigInteger.ONE;
		while(b.signum() > 0){
			BigInteger c = a.divide(b);
			BigInteger d;
			d = a; a = b; b = d.mod(b);
			d = p; p = q; q = d.subtract(c.multiply(q));
			d = r; r = s; s = d.subtract(c.multiply(s));
		}
		return new BigInteger[]{a, p, r};
	}

	public static BigInteger bi(long x){ return BigInteger.valueOf(x); }

	public static BigInteger crtx(long[] divs, long[] mods)
	{
		BigInteger div = bi(divs[0]), mod = bi(mods[0]);
		for(int i = 1;i < divs.length;i++){
			BigInteger[] apr = exGCD(div, bi(divs[i]));
			BigInteger mm = bi(mods[i]).subtract(mod);
			if(mm.mod(apr[0]).signum() != 0)return bi(-1);
			BigInteger da = div.divide(apr[0]);
			BigInteger ndiv = bi(divs[i]).multiply(da);
			BigInteger nmod = apr[1].multiply(mm).multiply(da).add(mod).mod(ndiv);
			if(nmod.signum() < 0)nmod = nmod.add(ndiv);
			div = ndiv;
			mod = nmod;
		}
		return mod;
	}

	// A^e*v
	public static int[] pow(int[][] A, int[] v, long e, int mod)
	{
		int[][] MUL = A;
		for(;e > 0;e>>>=1) {
			if((e&1)==1)v = mul(MUL, v, mod);
			MUL = p2(MUL, mod);
		}
		return v;
	}

	public static long[] exGCD(long a, long b)
	{
		long p = 1, q = 0, r = 0, s = 1;
		while(b > 0){
			long c = a / b;
			long d;
			d = a; a = b; b = d % b;
			d = p; p = q; q = d - c * q;
			d = r; r = s; s = d - c * s;
		}
		return new long[]{a, p, r};
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new E2().run();
	}

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

//package round122;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class E2 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int M2 = 1<<13;
		int M5 = 5*5*5*5*5*5*5*5*5*5*5*5*5;

		long f = nl();
		int x2 = (int)(f % M2);
		int[] fa2 = new int[M2];
		{
			int[] a = new int[1<<14];
			a[0] = 0;
			a[1] = 1;
			Arrays.fill(fa2, -1);
			fa2[0] = 0;
			fa2[1] = 1;
			for(int i = 2;i < 13000;i++){
				a[i] = (a[i-1] + a[i-2]) % M2;
				if(fa2[a[i]] == -1)fa2[a[i]] = i;
			}
			if(fa2[x2] == -1){
				out.println(-1);
				return;
			}
		}

		int f5 = (int)(f%5);
		List<Long> l = new ArrayList<Long>();
		{
			int[] a = new int[20];
			a[0] = 0;
			a[1] = 1;
			for(int i = 2;i < 4*5;i++){
				a[i] = (a[i-1] + a[i-2]) % 5;
			}
			for(int i = 0;i < 4*5;i++){
				if(a[i] == f5){
					l.add((long)i);
				}
			}
		}

		int[][] F = {
				{1, 1}, {1, 0}
		};
		for(long m = 25;m <= M5;m*=5){
			int fm = (int)(f % m);
			List<Long> nl = new ArrayList<Long>();
			for(long ll : l){
				for(int k = 0;k < 5;k++){
					long ne = ll+k*4*(m/5);
					long nf = 0;
					if(ne == 0){
						nf = 0;
					}else{
						nf = pow(F, new int[]{1, 0}, ne-1, (int)m)[0];
					}
					if(nf == fm){
						nl.add(ne);
					}
				}
			}
			l = nl;
		}

		long min = Long.MAX_VALUE;
		for(long ll : l){
			long num = crt(M2*3/2, fa2[x2], 4L*M5, ll);
			if(num >= 0){
				min = Math.min(min, num);
			}
		}
		if(min == Long.MAX_VALUE){
			out.println(-1);
		}else{
			out.println(min);
		}
	}

	public static long crt(long p, long m, long q, long n)
	{
		long[] apr = exGCD(p, q);
		if((n - m) % apr[0] != 0)return -1;
		long mod = p * q / apr[0];
		long a = (apr[1] * (n - m) / apr[0] * p + m) % mod;
		if(a < 0)a += mod;
		return a;
	}

	// int行列*ベクトル
	public static int[] mul(int[][] A, int[] v, int mod)
	{
		int m = A.length;
		int n = v.length;
		int[] w = new int[m];
		for(int i = 0;i < m;i++){
			long sum = 0;
			for(int k = 0;k < n;k++){
				sum += (long)A[i][k] * v[k];
				sum %= mod;
			}
			w[i] = (int)sum;
		}
		return w;
	}

	// int行列の2乗
	public static int[][] p2(int[][] A, int mod)
	{
		int n = A.length;
		int[][] C = new int[n][n];
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				long sum = 0;
				for(int k = 0;k < n;k++){
					sum += (long)A[i][k] * A[k][j];
					sum %= mod;
				}
				C[i][j] = (int)sum;
			}
		}
		return C;
	}

	// A^e*v
	public static int[] pow(int[][] A, int[] v, long e, int mod)
	{
		int[][] MUL = A;
		for(;e > 0;e>>>=1) {
			if((e&1)==1)v = mul(MUL, v, mod);
			MUL = p2(MUL, mod);
		}
		return v;
	}

	public static long[] exGCD(long a, long b)
	{
		long p = 1, q = 0, r = 0, s = 1;
		while(b > 0){
			long c = a / b;
			long d;
			d = a; a = b; b = d % b;
			d = p; p = q; q = d - c * q;
			d = r; r = s; s = d - c * s;
		}
		return new long[]{a, p, r};
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new E2().run();
	}

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}