#include <bits/stdc++.h>
const unsigned long long maxn = 70;
unsigned long long n, flg, KKK, ans;
unsigned long long f[maxn], mul10[maxn], cycle[maxn], a[maxn];
struct matrix {
  unsigned long long len, wid;
  unsigned long long mt[3][3];
} pre[14][45];
inline unsigned long long min(unsigned long long a, unsigned long long b) {
  return a < b ? a : b;
}
unsigned long long modmul(unsigned long long a, unsigned long long b,
                          unsigned long long mod) {
  unsigned long long res = 0;
  while (b) {
    if (b & 1) {
      res += a;
      if (res > mod) res -= mod;
    }
    a += a;
    if (a > mod) a -= mod;
    b >>= 1;
  }
  return res;
}
matrix mul(matrix a, matrix b, unsigned long long mod) {
  matrix res;
  res.len = a.len, res.wid = b.wid;
  for (unsigned long long u = 1; u <= a.len; u++)
    for (unsigned long long v = 1; v <= b.wid; v++) res.mt[u][v] = 0;
  for (unsigned long long u = 1; u <= a.len; u++)
    for (unsigned long long v = 1; v <= b.wid; v++)
      for (unsigned long long w = 1; w <= a.wid; w++)
        res.mt[u][v] =
            (res.mt[u][v] + modmul(a.mt[u][w], b.mt[w][v], mod)) % mod;
  return res;
}
unsigned long long calc(unsigned long long b, unsigned long long kk,
                        unsigned long long mod) {
  matrix a, res;
  res.len = 1, res.wid = 2, res.mt[1][1] = 0, res.mt[1][2] = 1;
  for (unsigned long long i = 0; i <= 44; i++)
    if ((b >> i) & 1) res = mul(res, pre[kk][i], mod);
  return res.mt[1][1];
}
void dfs(unsigned long long len, unsigned long long now) {
  if (now > ans) return;
  if (len == n + 1) {
    flg = 1, ans = min(ans, now);
    return;
  }
  for (unsigned long long i = 0; i < 10; i++) {
    unsigned long long k =
        (modmul(i, cycle[len], cycle[len + 1]) + now) % cycle[len + 1];
    if (calc(k, len, mul10[len]) == a[len]) dfs(len + 1, k);
  }
}
signed main() {
  f[0] = 0, f[1] = 1;
  for (unsigned long long i = 2; i <= 60; i++) f[i] = f[i - 1] + f[i - 2];
  cycle[0] = 6, mul10[0] = 1;
  for (unsigned long long i = 1; i <= 19; i++)
    cycle[i] = 10ll * cycle[i - 1], mul10[i] = 10ll * mul10[i - 1];
  for (unsigned long long i = 1; i <= 13; i++) {
    pre[i][0].len = pre[i][0].wid = 2, pre[i][0].mt[1][1] = 0,
    pre[i][0].mt[1][2] = pre[i][0].mt[2][1] = pre[i][0].mt[2][2] = 1;
    for (unsigned long long j = 1; j <= 44; j++)
      pre[i][j] = mul(pre[i][j - 1], pre[i][j - 1], mul10[i]);
  }
  scanf("%llu", &KKK);
  n = 13, ans = 10000000000000000;
  for (unsigned long long i = 1; i <= n; i++)
    a[i] = a[i - 1] + KKK % 10 * mul10[i - 1], KKK /= 10;
  for (unsigned long long i = 0; i < 60; i++)
    if (f[i] % 10 == a[1]) dfs(1, i);
  if (flg == 0)
    puts("-1");
  else
    printf("%llu\n", ans);
  return 0;
}
