#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using pii = pair<LL, LL>;
using VI = vector<LL>;
LL mod;
inline LL M(LL first, LL second) {
  return (first * second -
          (LL)(first / (long double)mod * second + 1e-5) * mod + mod) %
         mod;
}
inline pii operator*(const pii& a, const pii& b) {
  return {(M(a.first, b.first) + M(a.second, b.second)) % mod,
          (M(a.first, b.second) + M(a.second, b.first + b.second)) % mod};
}
pii f(LL n) {
  pii ans = {1, 0}, a = {0, 1};
  for (; n; n >>= 1, a = a * a)
    if (n & 1) ans = ans * a;
  return ans;
}
int main() {
  VI first(1), t;
  LL g;
  cin >> g;
  LL z = g, T = 1, S = 1;
  mod = 1;
  for (int i = 0; i < 26; i++, S = T, first = t) {
    for (mod *= (i > 12) * 3 + 2; f(T) != pii(1, 0); T += S)
      ;
    t.clear();
    for (int i = T / S; i--;) {
      for (LL r : first) {
        LL v = r + i * S;
        if (f(v).second == z % mod) {
          t.push_back(v);
        }
      }
    }
  }
  if (first.empty()) first.push_back(-1);
  cout << (LL)first.back() << endl;
}
