#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long MOD = 1e13;
struct Matrix {
  int n, m;
  long long a[3][3];
  Matrix() { memset(a, 0, sizeof(a)); }
  void debug() {
    cout << n << " " << m << endl;
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= m; ++j) {
        cout << a[i][j] << " ";
        if (j == m) cout << endl;
      }
  }
};
Matrix multiplication(Matrix A, Matrix B) {
  Matrix result;
  memset(result.a, 0, sizeof(result.a));
  if (A.m != B.n) {
    cout << "------\n";
    cout << "|erro|\n";
    cout << "------\n";
    cout << "A can't multiply B \n";
    exit(0);
  }
  result.n = A.n;
  result.m = B.m;
  for (int i = 1; i <= A.n; ++i) {
    for (int j = 1; j <= B.m; ++j) {
      for (int k = 1; k <= A.m; ++k) {
        __int128 A_, B_;
        A_ = A.a[i][k];
        B_ = B.a[k][j];
        result.a[i][j] += A_ * B_ % MOD;
        result.a[i][j] %= MOD;
      }
    }
  }
  return result;
}
Matrix quick_pow(Matrix A, long long times) {
  if (times == 0) {
    Matrix res;
    res.m = res.n = A.n;
    memset(res.a, 0, sizeof(res.a));
    for (int i = 1; i <= res.m; ++i) {
      res.a[i][i] = 1;
    }
    return res;
  }
  Matrix res = quick_pow(A, times >> 1);
  res = multiplication(res, res);
  if (times & 1) res = multiplication(res, A);
  return res;
}
int main() {
  long long f;
  scanf("%lld", &f);
  long long f0, f1;
  f0 = 0, f1 = 1;
  long long p = 0;
  vector<long long> s;
  while (true) {
    if (p && f0 == 0 && f1 == 1) break;
    if (f0 == f % 10000000) {
      s.push_back(p);
    }
    long long f2 = (f0 + f1) % (10000000);
    f0 = f1;
    f1 = f2;
    ++p;
  }
  Matrix trans;
  trans.n = trans.m = 2;
  trans.a[2][1] = 1;
  trans.a[1][2] = 1;
  trans.a[2][2] = 1;
  trans = quick_pow(trans, p);
  long long ans = 1e16;
  for (auto it : s) {
    Matrix tmptrans;
    tmptrans.n = tmptrans.m = 2;
    tmptrans.a[2][1] = 1;
    tmptrans.a[1][2] = 1;
    tmptrans.a[2][2] = 1;
    tmptrans = quick_pow(tmptrans, it);
    long long x = it;
    for (int i = 1; i <= 2000000; ++i) {
      if (x > ans) break;
      if (tmptrans.a[2][1] == f) {
        ans = min(ans, x);
        break;
      }
      x += p;
      tmptrans = multiplication(tmptrans, trans);
    }
  }
  if (ans < 1e15)
    cout << ans << endl;
  else
    puts("-1");
  return 0;
}
