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, ...

Input

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. 

Output

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.

Examples

Input

13


Output

7


Input

377


Output

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

public class Problem {

    private static final InputStream inputStream = System.in;
    private static final FastScanner in = new FastScanner(inputStream);

    public static void main(String[] args) {
        solve();
    }

    private static final long mod = (long) Math.pow(10, 13);

    public static void solve() {
        long fib = scanLong();
        long p = 1;
        long mod = 1;
        long[][] mp = new long[][] {new long[] {0, 1}, new long[] {1, 1}};
        List<Candidate> sets = new ArrayList<>();
        sets.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 np = p;
            long[][] nmp = mp;
            while (nmp[0][1] % mod != 0 || nmp[1][1] % mod != 1) {
                nmp = mul(nmp, mp);
                np += p;
            }
            List<Candidate> newSets = new ArrayList<>();
            for (Candidate old : sets) {
                long[][] trans = old.trans;
                for (long noffset = old.offset; noffset < np; noffset += p) {
                    if ((trans[0][1] % mod == fib % mod)) {
                        newSets.add(new Candidate(noffset, trans));
                    }
                    trans = mul(trans, mp);
                }
            }
            sets = newSets;
            p = np;
            mp = nmp;
        }
        long min = Long.MAX_VALUE;
        for (Candidate c : sets) {
            min = Math.min(min, c.offset);
        }
        if (min == Long.MAX_VALUE) {
            System.out.println(-1);
        } else {
            System.out.println(min);
        }
    }

    private static long[][] mul(long[][] first, long[][] second) {
        long[][] result = 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(first[i][k]).multiply(BigInteger.valueOf(second[k][j])));
                }
                result[i][j] = sum.mod(BigInteger.valueOf(Problem.mod)).longValue();
            }
        }
        return result;
    }

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

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

        @Override
        public String toString() {
            return offset + " " + Arrays.deepToString(trans);
        }
    }

    static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer st;

        public FastScanner(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
        }

        private void read() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

        public String next() {
            read();
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

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

    private static int scanInt() {
        return Integer.parseInt(in.next());
    }

    private static long scanLong() {
        return Long.parseLong(in.next());
    }

    private static String next() {
        return in.next();
    }

    private static int nextInt() {
        return in.nextInt();
    }

    private static int[] nextArrayInt(int len) {
        int[] array = new int[len];
        for (int i = 0; i < len; i++) {
            array[i] = scanInt();
        }
        return array;
    }
}