#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> ans(14);
long long mod = 10;
long long multiply(long long a, long long b) {
  long long ans = 0;
  while (b) {
    if (b % 2 == 1) {
      ans += a;
      ans %= mod;
    }
    a += a;
    a %= mod;
    b /= 2;
  }
  return ans;
}
vector<long long> period(14);
void find_period() {
  period[1] = 60;
  period[2] = 300;
  period[3] = 1500;
  for (int i = 4; i <= 13; ++i) period[i] = period[i - 1] * 10;
}
vector<vector<long long>> matr(2, vector<long long>(2));
vector<long long> vec(2);
vector<long long> result(2);
vector<vector<long long>> binpow(long long n, long long MOD) {
  if (n <= 1) return matr;
  if (n % 2 == 1) {
    vector<vector<long long>> a = matr;
    vector<vector<long long>> b = binpow(n - 1, MOD);
    matr[0][0] =
        (multiply(a[0][0], b[0][0]) + multiply(a[0][1], b[1][0])) % MOD;
    matr[0][1] = (multiply(a[0][0], b[0][1]) + (a[0][1], b[1][1])) % MOD;
    matr[1][0] = (multiply(a[1][0], b[0][0]) + (a[1][1], b[1][0])) % MOD;
    matr[1][1] = (multiply(a[1][0], b[0][1]) + (a[1][1], b[1][1])) % MOD;
    return matr;
  }
  if (n % 2 == 0) {
    vector<vector<long long>> b = binpow(n / 2, MOD);
    vector<vector<long long>> a = b;
    matr[0][0] =
        (multiply(a[0][0], b[0][0]) + multiply(a[0][1], b[1][0])) % MOD;
    matr[0][1] =
        (multiply(a[0][0], b[0][1]) + multiply(a[0][1], b[1][1])) % MOD;
    matr[1][0] =
        (multiply(a[1][0], b[0][0]) + multiply(a[1][1], b[1][0])) % MOD;
    matr[1][1] =
        (multiply(a[1][0], b[0][1]) + multiply(a[1][1], b[1][1])) % MOD;
    return matr;
  }
}
long long find_F_mod(long long n, long long MOD) {
  matr[0][0] = 0;
  matr[0][1] = 1;
  matr[1][0] = 1;
  matr[1][1] = 1;
  vec[0] = 0;
  vec[1] = 1;
  result[0] = 0;
  result[1] = 0;
  binpow(n, MOD);
  result[0] = (multiply(vec[0], matr[0][0]) % MOD +
               multiply(vec[1], matr[1][0]) % MOD) %
              MOD;
  result[1] = (multiply(vec[0], matr[0][1]) % MOD +
               multiply(vec[1], matr[1][1]) % MOD) %
              MOD;
  return result[0];
}
long long f;
void find_for_period_10() {
  vector<long long> F(60);
  F[0] = 0;
  F[1] = 1;
  for (int i = 0; i < 60; ++i) {
    if (i > 1) F[i] = (F[i - 2] + F[i - 1]) % mod;
    if (F[i] == f % mod) ans[1].push_back(i);
  }
}
int main() {
  find_period();
  cin >> f;
  if (f <= 1) {
    cout << f << endl;
    return 0;
  }
  find_for_period_10();
  long long i;
  for (i = 2; i <= 13; ++i) {
    mod *= 10;
    long long cur = f % mod;
    long long chek = 0;
    long long nomer, Fibon;
    while (chek < period[i]) {
      for (int j = 0; j < ans[i - 1].size(); ++j) {
        nomer = ans[i - 1][j] + chek;
        Fibon = find_F_mod(nomer, mod);
        if (Fibon == cur) {
          ans[i].push_back(nomer);
        }
      }
      chek += period[i - 1];
    }
  }
  if (ans[13].empty())
    cout << -1 << endl;
  else
    cout << ans[13][0] << endl;
  return 0;
}
