#include <bits/stdc++.h>
using namespace std;
struct mat {
  long long a[2][2];
  mat() { memset(a, 0, sizeof(a)); }
};
mat mult(mat a, mat b, int mod) {
  mat ans;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++)
        ans.a[i][j] = (ans.a[i][j] + a.a[i][k] * b.a[k][j]) % mod;
  return ans;
}
mat pow(mat a, long long b, int mod) {
  mat ans;
  for (int i = 0; i < 2; i++) ans.a[i][i] = 1;
  while (b) {
    if (b & 1) ans = mult(ans, a, mod);
    a = mult(a, a, mod);
    b >>= 1;
  }
  return ans;
}
long long fib(long long n, long long mod) {
  if (n == 0) return 0;
  mat a;
  a.a[0][0] = a.a[0][1] = a.a[1][0] = 1;
  a = pow(a, (n - 1), mod);
  return a.a[0][0];
}
vector<long long> gao(long long f, long long mod) {
  vector<long long> ans;
  if (mod == 2) {
    for (int i = 0; i < 3; i++)
      if (fib(i, mod) == f) ans.push_back(i);
    return ans;
  }
  if (mod == 5) {
    for (int i = 0; i < 20; i++)
      if (fib(i, mod) == f) ans.push_back(i);
    return ans;
  }
  if (mod % 2 == 0) {
    long long m = mod / 2;
    vector<long long> temp = gao(f % m, m);
    for (int i = 0; i < temp.size(); i++)
      for (int j = 0; j < 2; j++)
        if (fib(temp[i] + j * m * 3 / 2, mod) == f)
          ans.push_back(temp[i] + j * m * 3 / 2);
    return ans;
  }
  if (mod % 5 == 0) {
    long long m = mod / 5;
    vector<long long> temp = gao(f % m, m);
    for (int i = 0; i < temp.size(); i++)
      for (int j = 0; j < 5; j++)
        if (fib(temp[i] + j * m * 4, mod) == f)
          ans.push_back(temp[i] + j * m * 4);
    return ans;
  }
}
int main() {
  long long f;
  while (~scanf("%I64d", &f)) {
    long long five = 1;
    for (int i = 0; i < 13; i++) five *= 5;
    long long two = 1 << 13;
    long long Tfive = five * 4;
    long long Ttwo = two / 2 * 3;
    vector<long long> gfive = gao(f % five, five);
    vector<long long> gtwo = gao(f % two, two);
    if (gfive.size() == 0 || gtwo.size() == 0) {
      puts("-1");
      continue;
    }
    long long ans = 1LL << 60;
    for (int i = 0; i < gfive.size(); i++)
      for (int j = 0; j < gtwo.size(); j++) {
        for (long long k = gfive[i]; k < Tfive * Ttwo / 4; k += Tfive)
          if (k % Ttwo == gtwo[j]) {
            ans = min(ans, k);
            break;
          }
      }
    printf("%I64d\n", ans);
  }
}
