#include <bits/stdc++.h>
using namespace std;
long long mod;
long long mul(long long x, long long y, long long z) {
  return (x * y - (long long)(x / (long double)z * y + 1e-3) * z + z) % z;
}
pair<long long, long long> solve(long long n) {
  if (n == 0) return make_pair(0, 1);
  if (n & 1) {
    pair<long long, long long> temp = solve(n - 1);
    return make_pair(temp.second, (temp.first + temp.second) % mod);
  } else {
    pair<long long, long long> temp = solve(n >> 1);
    return make_pair(mul(temp.first, 2 * temp.second - temp.first + mod, mod),
                     (mul(temp.first, temp.first, mod) +
                      mul(temp.second, temp.second, mod)) %
                         mod);
  }
}
long long Fib(long long n) {
  pair<long long, long long> ans = solve(n);
  return ans.first;
}
long long v;
vector<long long> p[15];
long long work() {
  mod = 10;
  long long L = 60;
  for (int i = 1; i <= 60; i++)
    if (Fib(i) == v % mod) p[0].push_back(i);
  for (int i = 0; i < 12; i++) {
    mod *= 10;
    for (int j = 0; j < p[i].size(); j++) {
      long long k = p[i][j];
      for (int r = 0; r < 10; r++)
        if (Fib(L * r + k) == v % mod) p[i + 1].push_back(L * r + k);
    }
    L *= 10;
  }
  if (p[12].size() == 0) return -1;
  long long ans = p[12][0];
  for (int i = 1; i < p[12].size(); i++) ans = min(ans, p[12][i]);
  return ans;
}
int main() {
  cin >> v;
  cout << work() << endl;
  return 0;
}
