#include <bits/stdc++.h>
using namespace std;
long long n, m, a, b = 1, c, can[100000 * 10], cc, M, tmp[100000 * 10],
                   ans = 0x3f3f3f3f3f3f3f3f, XH;
inline long long cheng(long long u, long long v) {
  long long res = 0;
  for (; v; v >>= 1) {
    if (v & 1) res = (res + u) % M;
    u = u * 2 % M;
  }
  return res;
}
struct Jz {
  long long num[2][2];
  Jz() { memset(num, 0, sizeof(num)); }
  Jz operator*(const Jz &u) const {
    Jz res;
    long long i, j, k;
    for (i = 0; i < 2; i++) {
      for (j = 0; j < 2; j++) {
        for (k = 0; k < 2; k++) {
          res.num[i][j] = (res.num[i][j] + cheng(num[i][k], u.num[k][j])) % M;
        }
      }
    }
    return res;
  }
} dw;
inline Jz po(Jz u, long long v) {
  Jz res;
  res.num[0][0] = res.num[1][1] = 1;
  for (; v;) {
    if (v & 1) res = res * u;
    u = u * u;
    v >>= 1;
  }
  return res;
}
inline long long ask(long long u) {
  Jz res = po(dw, u);
  return res.num[0][0];
}
int main() {
  dw.num[0][1] = dw.num[1][0] = dw.num[1][1] = 1;
  long long i, j, k, t;
  cin >> n;
  t = n % 100000;
  for (i = 1;; i++) {
    if (t == a) can[++cc] = i;
    c = (a + b) % 100000;
    a = b, b = c;
    if (!a && b == 1) break;
  }
  for (M = 100000 * 10, XH = 150000; M <= (long long)1e13; M *= 10, XH *= 10) {
    t = n % M, k = 0;
    for (i = 1; i <= cc; i++) {
      for (j = 0; j <= 9; j++) {
        if (ask(can[i] + XH * j) % M == t) {
          tmp[++k] = can[i] + XH * j;
        }
      }
    }
    for (i = 1; i <= k; i++) can[i] = tmp[i];
    cc = k;
  }
  if (!cc) {
    puts("-1");
    return 0;
  }
  for (i = 1; i <= cc; i++) ans = min(ans, can[i]);
  cout << ans - 1;
}
