#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e13;
long long mul(long long x, long long y) {
  return (x * y - (long long)((long double)x / mod * y) * mod + mod) % mod;
}
inline long long mul2(long long x, long long y) {
  long long ans = 0;
  while (y) {
    if (y & 1) (ans += x) %= mod;
    (x <<= 1) %= mod;
    y >>= 1;
  }
  return ans;
}
struct M {
  long long a[2][2];
};
inline M operator*(const M &a, const M &b) {
  M ans = {};
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++) {
        ans.a[i][j] = (ans.a[i][j] + mul(a.a[i][k], b.a[k][j])) % mod;
        if (mul(a.a[i][k], b.a[k][j]) != mul2(a.a[i][k], b.a[k][j])) {
          cout << endl;
        }
      }
  return ans;
}
inline long long fib(long long n) {
  if (n <= 2) return (bool)n;
  M ans = (M){1, 1, 0, 1}, base = {1, 1, 1, 0};
  n -= 2;
  while (n) {
    if (n & 1) ans = ans * base;
    base = base * base;
    n >>= 1;
  }
  return ans.a[0][0];
}
int main() {
  int i, k;
  long long n, p = 10, l = 60;
  cin >> n;
  vector<long long> v[13];
  vector<long long>::iterator it;
  for (i = 0; i < l; i++)
    if (fib(i) % p == n % p) v[0].push_back(i);
  for (i = 0; i < 12; i++) {
    p *= 10;
    for (it = v[i].begin(); it != v[i].end(); it++) {
      for (k = 0; k < 10; k++)
        if (fib(*it + k * l) % p == n % p) v[i + 1].push_back(*it + k * l);
    }
    l *= 10;
  }
  cout << (v[12].empty() ? -1 : *min_element(v[12].begin(), v[12].end()))
       << endl;
  return 0;
}
