#include <bits/stdc++.h>
using namespace std;
struct matrix {
  long long int a[2][2];
} mat1, mat, matmp, matp, matped;
long long int num, A, B, fa, fb, MOD, ans, posA[100], posB[100];
long long int times(long long int x, long long int y) {
  long long int b, re = 0, tmp;
  int i, j;
  for (b = 1, i = 0; b <= y; b *= 2, i++) {
    if (b & y) {
      tmp = x;
      for (j = 1; j <= i; j++) tmp = (tmp * 2) % MOD;
      re = (re + tmp) % MOD;
    }
  }
  return re;
}
matrix multi(matrix ma, matrix mb) {
  int i, j, k;
  matrix mre;
  mre.a[0][0] = mre.a[0][1] = mre.a[1][0] = mre.a[1][1] = 0;
  for (k = 0; k <= 1; k++)
    for (i = 0; i <= 1; i++)
      for (j = 0; j <= 1; j++)
        mre.a[i][j] = (mre.a[i][j] + times(ma.a[i][k], mb.a[k][j])) % MOD;
  return mre;
}
matrix matpow(long long int p) {
  long long int b;
  mat1.a[0][0] = 0;
  mat1.a[1][1] = mat1.a[1][0] = mat1.a[0][1] = 1;
  mat.a[0][0] = mat.a[1][1] = 1;
  mat.a[1][0] = mat.a[0][1] = 0;
  for (b = 1; b <= p; b *= 2) {
    if (b & p) {
      matmp = multi(mat1, mat);
      mat = matmp;
    }
    matmp = multi(mat1, mat1);
    mat1 = matmp;
  }
  return mat;
}
bool check() {
  long long int val = (matp.a[0][1] + matp.a[1][1]) % MOD;
  if (val == num) return true;
  return false;
}
int main() {
  cin >> num;
  A = (1 << 13);
  B = 1953125;
  MOD = (long long int)(10000000000000);
  fa = num % A;
  fb = num % B;
  ans = -1;
  long long int i, j, pedA, pedB, cntA, cntB, ped, tmp, k, x = 1, y = 1, pos, p;
  int j1;
  for (i = 1, j1 = 0;; i++) {
    if (i > 1 && x == 1 && y == 1) break;
    if (x == fa) posA[++j1] = i;
    tmp = x + y;
    x = y;
    y = tmp % A;
  }
  cntA = j1;
  pedA = i - 1;
  for (i = 1, j1 = 0;; i++) {
    if (i > 1 && x == 1 && y == 1) break;
    if (x == fb) posB[++j1] = i;
    tmp = x + y;
    x = y;
    y = tmp % B;
  }
  cntB = j1;
  pedB = i - 1;
  ped = pedA * pedB;
  for (i = 1; i <= cntA; i++)
    for (j = 1; j <= cntB; j++) {
      x = posA[i];
      y = posB[j];
      pos = -1;
      for (k = 0; k < pedA; k++)
        if ((y + pedB * k - x) % pedA == 0) {
          pos = y + pedB * k;
          matped = matpow(ped);
          matp = matpow(pos - 2);
          for (p = pos; p <= MOD * 20 && (ans == -1 || p < ans); p += ped) {
            if (check()) {
              ans = p;
              break;
            }
            matmp = multi(matp, matped);
            matp = matmp;
          }
        }
    }
  cout << ans;
}
