#include <bits/stdc++.h>
using namespace std;
const long long INF = 100000000000000;
long long MnoInt(long long a, long long b, long long MOD) {
  long long w = 0;
  for (long long i = 0; i < 60; ++i) {
    long long skl = a % MOD;
    if ((b & (1LL << i)) > 0) {
      for (int j = 0; j < i; ++j) skl = (skl * 2) % MOD;
      w = (w + skl) % MOD;
    }
  }
  return w;
}
vector<vector<long long> > MnoMat(vector<vector<long long> > a,
                                  vector<vector<long long> > b, long long MOD) {
  vector<vector<long long> > c(2, vector<long long>(2, 0));
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j)
      for (int k = 0; k < 2; ++k)
        c[i][j] = (c[i][j] + MnoInt(a[i][k], b[k][j], MOD)) % MOD;
  return c;
}
vector<vector<long long> > Pot(vector<vector<long long> > p, long long w,
                               long long MOD) {
  vector<vector<long long> > id(2, vector<long long>(2, 0));
  id[0][0] = id[1][1] = 1;
  if (w == 0) return id;
  if (w % 2 == 0) {
    vector<vector<long long> > pol = Pot(p, w / 2, MOD);
    return MnoMat(pol, pol, MOD);
  }
  return MnoMat(Pot(p, w - 1, MOD), p, MOD);
}
long long Fib(long long n, long long MOD) {
  if (n == 0) return 0;
  if (n == 1) return 1;
  vector<vector<long long> > mat(2, vector<long long>(2, 1));
  mat[1][1] = 0;
  mat = Pot(mat, n - 1, MOD);
  return mat[0][0];
}
int main() {
  ios_base::sync_with_stdio(0);
  long long R;
  cin >> R;
  vector<vector<long long> > nry(14);
  long long MOD = 1000, cykl = 1500;
  for (long long i = 0; i < cykl; ++i)
    if (Fib(i, MOD) == R % MOD) nry[3].push_back(i);
  for (long long i = 4; i <= 13; ++i) {
    MOD *= 10;
    cykl *= 10;
    for (long long j = 0; j < nry[i - 1].size(); ++j)
      for (long long k = 0; k <= 9; ++k)
        if (Fib(nry[i - 1][j] + k * (cykl / 10), MOD) == R % MOD)
          nry[i].push_back(nry[i - 1][j] + k * (cykl / 10));
  }
  long long odp = INF;
  for (int i = 0; i < nry[13].size(); ++i) odp = min(odp, nry[13][i]);
  if (odp == INF) odp = -1;
  cout << odp;
  return 0;
}
