#include <bits/stdc++.h>
using namespace std;
const int N = 1;
const double eps = 1e-7;
const int ten = 10000000;
const int oo = 1000000000;
const int base = 1000000000;
const long long f = 10000000000000LL;
struct Integer {
  long long a, b, c;
  Integer(long long x = 0) : a(0), b(x / base), c(x % base) {}
};
long long fib[15][3];
long long cycle[15];
Integer operator*(Integer a, Integer b) {
  Integer product;
  product.c = a.c * b.c;
  product.b = a.b * b.c + a.c * b.b + product.c / base;
  product.a = a.a * b.c + a.b * b.b + a.c * b.a + product.b / base;
  product.c %= base;
  product.b %= base;
  product.a %= base;
  return product;
}
Integer operator+(Integer a, Integer b) {
  Integer sum;
  sum.c = a.c + b.c;
  sum.b = a.b + b.b + sum.c / base;
  sum.a = a.a + b.a + sum.b / base;
  sum.c %= base;
  sum.b %= base;
  sum.a %= base;
  return sum;
}
Integer operator%(Integer a, long long b) {
  Integer reminder;
  reminder.a = 0;
  if (b / base > 1) {
    reminder.b = a.b % (b / base);
  } else {
    reminder.b = 0;
  }
  if (b > base) {
    reminder.c = a.c;
  } else {
    reminder.c = b;
  }
  return reminder;
}
bool operator!=(Integer a, long long b) {
  return a.a != 0 || a.b != b / base || a.c != b % base;
}
long long mult(long long a, long long b, long long md) {
  long long ret = 0;
  for (; b; b >>= 1) {
    if (b & 1) {
      ret = (ret + a) % md;
    }
    a = (a + a) % md;
  }
  return ret;
}
long long getfib(long long n, long long md) {
  n = n - 1;
  long long base[2][2] = {{1, 1}, {1, 0}};
  long long mat[2][2] = {{1, 0}, {0, 1}};
  for (; n; n >>= 1) {
    if (n & 1) {
      long long temp[2][2] = {{mat[0][0], mat[0][1]}, {mat[1][0], mat[1][1]}};
      mat[0][0] = (mult(temp[0][0], base[0][0], md) +
                   mult(temp[0][1], base[1][0], md)) %
                  md;
      mat[0][1] = (mult(temp[0][0], base[0][1], md) +
                   mult(temp[0][1], base[1][1], md)) %
                  md;
      mat[1][0] = (mult(temp[1][0], base[0][0], md) +
                   mult(temp[1][1], base[1][0], md)) %
                  md;
      mat[1][1] = (mult(temp[1][0], base[0][1], md) +
                   mult(temp[1][1], base[1][1], md)) %
                  md;
    }
    long long temp[2][2] = {{base[0][0], base[0][1]}, {base[1][0], base[1][1]}};
    base[0][0] =
        (mult(temp[0][0], temp[0][0], md) + mult(temp[0][1], temp[1][0], md)) %
        md;
    base[0][1] =
        (mult(temp[0][0], temp[0][1], md) + mult(temp[0][1], temp[1][1], md)) %
        md;
    base[1][0] =
        (mult(temp[1][0], temp[0][0], md) + mult(temp[1][1], temp[1][0], md)) %
        md;
    base[1][1] =
        (mult(temp[1][0], temp[0][1], md) + mult(temp[1][1], temp[1][1], md)) %
        md;
  }
  return mat[0][0];
}
void init() {
  cycle[0] = 1;
  cycle[1] = 60;
  long long pt = 100;
  for (int i = 2; i <= 13; ++i) {
    cycle[i] = cycle[i - 1];
    long long x = getfib(cycle[i - 1] + 1, pt), y = getfib(cycle[i - 1], pt),
              z = getfib(cycle[i - 1] - 1, pt);
    long long f0 = y, f1 = x;
    while (f0 != 0 || f1 != 1) {
      long long nf1 = (mult(f1, x, pt) + mult(f0, y, pt)) % pt;
      long long nf0 = (mult(f1, y, pt) + mult(f0, z, pt)) % pt;
      f1 = nf1;
      f0 = nf0;
      cycle[i] += cycle[i - 1];
    }
    pt *= 10;
  }
  for (int i = 1; i <= 13; ++i) {
    fib[i][0] = getfib(cycle[i] - 1, f);
    fib[i][1] = getfib(cycle[i], f);
    fib[i][2] = getfib(cycle[i] + 1, f);
  }
}
void print(Integer a) {
  if (a.a == 0) {
    if (a.b == 0) {
      cout << a.c << endl;
    } else {
      cout << a.b;
      stringstream s;
      s << a.c;
      string ss = s.str();
      cout << string(9 - ss.size(), '0') << ss << endl;
    }
  } else {
    cout << a.a;
    stringstream sb, sc;
    sb << a.b;
    sc << a.c;
    string ssb = sb.str();
    string ssc = sc.str();
    cout << string(9 - ssb.size(), '0') << ssb << string(9 - ssc.size(), '0')
         << ssc << endl;
  }
}
int main() {
  init();
  long long n;
  cin >> n;
  if (n == 0) {
    cout << 0 << endl;
  } else if (n == 1) {
    cout << 1 << endl;
  } else {
    long long t = 3, a0 = 1, a1 = 2, a2 = 1;
    long long ans = (long long)oo * oo;
    while (t <= cycle[7] && t <= ans) {
      a2 = (a1 + a0) % ten;
      a0 = a1;
      a1 = a2;
      ++t;
      if (a2 % ten == n % ten) {
        int d = 1;
        long long ac = t;
        Integer x(fib[7][2]), y(fib[7][1]), z(fib[7][0]);
        Integer f0(getfib(t - 1, f)), f1(getfib(t, f));
        while (f1 != n && d <= 1000000 && ac < ans) {
          Integer nf1((f1 * x + f0 * y) % f);
          Integer nf0((f1 * y + f0 * z) % f);
          f1 = nf1;
          f0 = nf0;
          ac += cycle[7];
          d++;
        }
        if (!(f1 != n)) {
          ans = min(ans, ac);
        }
      }
    }
    if (ans >= (long long)oo * oo) {
      cout << -1 << endl;
    } else {
      cout << ans << endl;
    }
  }
  return 0;
}
