#include <bits/stdc++.h>
using namespace std;
int MODs[2] = {(int)((long long)1e13 / (1 << 13)), 1 << 13};
int MOD;
struct matr {
  int h, w;
  vector<vector<int> > a;
  matr(int _h = 1, int _w = 1) : h(_h), w(_w) {
    a = vector<vector<int> >(h, vector<int>(w, 0));
    if (h == w)
      for (int i = 0; i < h; i++) a[i][i] = 1;
  }
  void operator*=(const matr &m) {
    assert(w == m.h);
    vector<vector<int> > newa(h, vector<int>(m.w, 0));
    for (int i = 0; i < h; i++)
      for (int j = 0; j < m.w; j++) {
        int &cur = newa[i][j];
        cur = 0;
        for (int y = 0; y < w; y++)
          cur = (cur + a[i][y] * (long long)m.a[y][j]) % MOD;
      }
    a = newa;
    w = m.w;
  }
  matr makepow(long long pw) {
    assert(w == h);
    matr now = *this;
    matr ans = matr(w, w);
    for (; pw; pw >>= 1) {
      if (pw & 1ll) ans *= now;
      now *= now;
    }
    return ans;
  }
  inline bool operator<(const matr &m) const {
    if (h != m.h) return h < m.h;
    if (w != m.w) return w < m.w;
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++)
        if (a[i][j] != m.a[i][j]) return a[i][j] < m.a[i][j];
    return 0;
  }
  void print() {
    fprintf(stderr, "matr:\n");
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++)
        fprintf(stderr, "%d%c", a[i][j], " \n"[j == w - 1]);
  }
};
matr init;
int gcdnow[2][2];
void gcd(int a, int b) {
  if (!b) return;
  int k = a / b;
  gcdnow[0][0] -= k * gcdnow[1][0], gcdnow[0][1] -= k * gcdnow[1][1];
  swap(gcdnow[0][0], gcdnow[1][0]), swap(gcdnow[0][1], gcdnow[1][1]);
  gcd(b, a % b);
}
int rs[2];
long long getF(long long pos) {
  for (int it = 0; it < 2; it++) {
    MOD = MODs[it];
    rs[it] = init.makepow(pos + 1).a[0][0];
  }
  gcdnow[0][0] = 1, gcdnow[0][1] = 0;
  gcdnow[1][0] = 0, gcdnow[1][1] = 1;
  gcd(MODs[0], MODs[1]);
  long long res = (gcdnow[0][0] * (long long)(rs[1] - rs[0])) % MODs[1];
  if (res < 0) res += MODs[1];
  assert(0 <= res && res < MODs[1]);
  res = res * MODs[0] + rs[0];
  assert(0 <= res && res < ((long long)1e13));
  assert((int)(res % MODs[0]) == rs[0] && (int)(res % MODs[1]) == rs[1]);
  return res;
}
int main() {
  init = matr(2, 2);
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) init.a[i][j] = (i || j);
  long long f;
  while (scanf("%lld", &f) >= 1) {
    long long per = 1;
    vector<long long> poss(1, 0);
    long long mod = 1;
    for (int power = 0; power < 13; power++) {
      mod *= 10;
      long long remf = f % mod;
      set<pair<long long, long long> > used;
      int k = 0;
      long long newper = 0;
      for (;; k++, newper += per) {
        pair<long long, long long> now(getF(newper) % mod,
                                       getF(newper + 1) % mod);
        if (used.count(now)) {
          break;
        } else
          used.insert(now);
      }
      vector<long long> newposs;
      for (int iter = 0; iter < (int)poss.size(); iter++) {
        long long pos = poss[iter];
        for (int i = 0; i < k; i++, pos += per) {
          long long Fn = getF(pos) % mod;
          if (Fn == remf) newposs.push_back(pos);
        }
      }
      poss = newposs;
      sort(poss.begin(), poss.end());
      poss.resize(unique(poss.begin(), poss.end()) - poss.begin());
      per = newper;
    }
    if (!poss.size())
      printf("-1\n");
    else
      printf(
          "%lld"
          "\n",
          poss[0]);
  }
  return 0;
}
