#include <bits/stdc++.h>
using namespace std;
int a, ta, b, tb, x[100], y[100], px, py, f[5];
long long F, ans, mod, tab, tmod;
struct mat {
  long long v[2][2];
} baza;
void init_fibo() {
  baza.v[0][0] = 0LL;
  baza.v[0][1] = baza.v[1][0] = baza.v[1][1] = 1LL;
}
long long prd(long long a, long long b) {
  long long ans = 0;
  for (int i = 0; (1LL << i) <= b; i++) {
    if (b & (1LL << i)) {
      ans += a;
      if (ans >= mod) ans -= mod;
    }
    a += a;
    if (a >= mod) a -= mod;
  }
  return ans;
}
mat prod(mat a, mat b) {
  mat c;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) {
      c.v[i][j] = 0;
      for (int k = 0; k < 2; k++)
        c.v[i][j] = ((long long)c.v[i][j] + prd(a.v[i][k], b.v[k][j])) % mod;
    }
  return c;
}
mat pow_mat(mat a, long long b) {
  mat ans;
  ans.v[0][0] = ans.v[1][1] = 1LL;
  ans.v[0][1] = ans.v[1][0] = 0LL;
  for (int i = 0; (1LL << i) <= b; i++) {
    if (b & (1LL << i)) ans = prod(ans, a);
    a = prod(a, a);
  }
  return ans;
}
long long get_Nth(long long N) {
  if (N == 0) return 0;
  if (N == 1) return 1;
  mat curr = pow_mat(baza, N - 1);
  return curr.v[1][1];
}
int main() {
  scanf("%I64d", &F);
  mod = 10000000000000LL;
  a = 8192, ta = 12288;
  b = 1953125, tb = 7812500;
  tmod = 15000000000000LL;
  tab = 24000000000LL;
  init_fibo();
  f[0] = 0, f[1] = 1;
  for (int i = 0; i < ta; i++) {
    if (i >= 2) f[i % 3] = (f[(i - 1) % 3] + f[(i - 2) % 3]) % a;
    if (F % a == f[i % 3]) x[++px] = i;
  }
  f[0] = 0, f[1] = 1;
  for (int i = 0; i < tb; i++) {
    if (i >= 2) f[i % 3] = (f[(i - 1) % 3] + f[(i - 2) % 3]) % b;
    if (F % b == f[i % 3]) y[++py] = i;
  }
  ans = -1;
  for (int I = 1; I <= px; I++)
    for (int J = 1; J <= py; J++) {
      int i = x[I], j = y[J];
      long long P = -1;
      for (int p = 0; p < ta; p++)
        if (((long long)1LL * p * tb + j - i) % ta == 0 &&
            (long long)1LL * p * tb + j >= i) {
          P = (long long)1LL * p * tb + j;
          break;
        }
      if (P == -1) continue;
      while (1) {
        if (get_Nth(P) == F) {
          if (ans == -1 || P < ans) ans = P;
          break;
        }
        P += tab;
        if (P >= tmod) break;
      }
    }
  printf("%I64d\n", ans);
  return 0;
}
