#include <bits/stdc++.h>
using namespace std;
long long num, mod, ans[100005], nxt[100005];
int cnt, cntn;
long long mul(long long a, long long b) {
  long long ret = 0;
  for (; b; b >>= 1, a = (a * 2) % mod)
    if (b & 1) ret = (ret + a) % mod;
  return ret;
}
struct Mat {
  long long a[2][2];
  int n, m;
  void Clear(int N, int M) {
    n = N, m = M;
    memset(a, 0, sizeof a);
  }
  void Unit(int sz) {
    Clear(sz, sz);
    for (int i = 0; i < sz; i++) a[i][i] = 1;
  }
  Mat operator*(const Mat &B) const {
    Mat ret;
    ret.Clear(n, B.m);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < B.m; j++)
        for (int k = 0; k < m; k++)
          ret.a[i][j] = (ret.a[i][j] + mul(a[i][k], B.a[k][j])) % mod;
    return ret;
  }
} A;
Mat pow(Mat base, long long k) {
  Mat ret;
  ret.Unit(base.n);
  for (; k; k >>= 1, base = base * base)
    if (k & 1) ret = ret * base;
  return ret;
}
long long F(long long id) {
  if (id == 1) return 1;
  if (id == 0) return 0;
  Mat B = pow(A, id - 2);
  return (B.a[0][0] + B.a[0][1]) % mod;
}
int main() {
  scanf("%I64d", &num);
  num %= 10000000000000ll;
  int a = 0, b = 1, c;
  long long *x = ans, *y = nxt, *t;
  if (a == num) y[cntn++] = 0;
  if (b == num) y[cntn++] = 1;
  for (int i = 2; i <= 1500; i++) {
    c = (a + b) % 1000;
    a = b, b = c;
    if (c == num % 1000) y[cntn++] = i;
  }
  t = x, x = y, y = t, cnt = cntn, cntn = 0;
  A.Clear(2, 2);
  A.a[0][0] = A.a[1][0] = A.a[0][1] = 1;
  long long pret = 1500;
  mod = 10000;
  for (; mod <= 10000000000000ll; mod *= 10, pret *= 10) {
    for (int i = 0; i <= 9; i++)
      for (int j = 0; j < cnt; j++)
        if (F(i * pret + x[j]) == num % mod) y[cntn++] = i * pret + x[j];
    t = x, x = y, y = t, cnt = cntn, cntn = 0;
  }
  sort(x, x + cnt);
  if (!cnt) x[0] = -1;
  printf("%I64d", x[0]);
}
