#include <bits/stdc++.h>
const int mn = 1050;
long long t[2][2] = {{1, 1}, {1, 0}};
long long v, mo, f[2][2], c[2][2], x[2][2];
long long s[mn], s1[mn], h, L, ans;
int n, m, i, j, k;
long long S(long long a, long long b) {
  long long res = 0, L = 1LL << 60;
  while (L) {
    res = res * 2 % mo;
    if ((b & L) != 0) res = (res + a) % mo;
    L >>= 1;
  }
  return res;
}
void mul(long long a[][2], long long b[][2], long long c[][2]) {
  c[0][0] = (S(a[0][0], b[0][0]) + S(a[0][1], b[1][0]));
  c[0][1] = (S(a[0][0], b[0][1]) + S(a[0][1], b[1][1]));
  c[1][0] = (S(a[1][0], b[0][0]) + S(a[1][1], b[1][0]));
  c[1][1] = (S(a[1][0], b[0][1]) + S(a[1][1], b[1][1]));
}
void dg(long long n) {
  if (n == 1) return;
  dg(n / 2);
  mul(x, x, c);
  if (n % 2)
    mul(c, t, x);
  else
    memcpy(x, c, sizeof c);
}
long long query(long long n) {
  if (n == 0) return 0;
  memset(f, 0, sizeof f);
  f[0][0] = 1, f[1][0] = 0;
  memcpy(x, t, sizeof t);
  dg(n);
  mul(x, f, c);
  return c[1][0];
}
int main() {
  scanf("%I64d", &v);
  L = 60, mo = 10;
  for (i = 0; i <= 59; ++i)
    if (query(i) == v % mo) s[++n] = i;
  for (i = 1; i <= 12; ++i) {
    mo *= 10;
    m = 0;
    for (j = 1; j <= n; ++j)
      for (k = 0; k <= 9; ++k) {
        h = k * L + s[j];
        if (query(h) == v % mo) s1[++m] = h;
      }
    L *= 10, n = m, memcpy(s, s1, sizeof s1);
  }
  if (!n) {
    printf("-1\n");
    return 0;
  }
  ans = s[1];
  for (i = 2; i <= n; ++i)
    if (s[i] < ans) ans = s[i];
  printf("%I64d\n", ans);
  return 0;
}
