#include <bits/stdc++.h>
using namespace std;
const int maxint = -1u >> 1;
const long long ST = 100000LL;
const long long ED = 10000000000000LL;
long long prd;
long long n;
long long mul(long long a, long long b, long long mod) {
  long long x = 0;
  while (b) {
    if (b & 1) x = (x + a) % mod;
    a = (a + a) % mod;
    b >>= 1;
  }
  return x;
}
void mul(long long a[][2], long long b[][2], long long mod) {
  long long c[2][2];
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      c[i][j] = 0;
      for (int k = 0; k < 2; ++k) {
        c[i][j] += mul(a[i][k], b[k][j], mod);
        if (c[i][j] >= mod) c[i][j] %= mod;
      }
    }
  }
  memcpy(a, c, sizeof(c));
}
void pow(long long a[][2], long long n, long long mod) {
  long long x[][2] = {{1, 0}, {0, 1}};
  while (n) {
    if (n & 1) mul(x, a, mod);
    mul(a, a, mod);
    n >>= 1;
  }
  memcpy(a, x, sizeof(x));
}
long long f(long long n, long long mod) {
  long long x[][2] = {{1, 1}, {1, 0}};
  pow(x, n, mod);
  return (x[1][0] % mod);
}
long long get_multi(long long prd, long long r) {
  long long res = 1;
  while (f(prd * res, r) != f(prd * res * 2, r) ||
         f(prd * res + 1, r) != f(prd * res * 2 + 1, r)) {
    ++res;
  }
  return res;
}
vector<long long> work(vector<long long> &v, long long prd, long long r) {
  vector<long long> res(v.begin(), v.end());
  while (r != ED) {
    v = res;
    res.clear();
    r *= 10;
    long long multi = get_multi(prd, r);
    for (int i = 0; i < (int)v.size(); ++i) {
      for (int j = 0; j < multi; ++j) {
        if (f(prd * j + v[i], r) == n % r) {
          res.push_back(prd * j + v[i]);
        }
      }
    }
    prd *= multi;
  }
  return res;
}
void init() {
  set<pair<int, int> > ss;
  int cnt = 0, r = ST;
  pair<int, int> now(0, 1);
  while (ss.find(now) == ss.end()) {
    ss.insert(now);
    ++cnt;
    now.first += now.second;
    now.first %= r;
    swap(now.first, now.second);
  }
  prd = cnt;
}
int main() {
  init();
  while (scanf("%I64d", &n) == 1) {
    pair<int, int> now(0, 1);
    int cnt = 0;
    long long r = ST;
    vector<long long> v;
    for (int i = 0; i < prd; ++i) {
      if (now.first == n % r) {
        v.push_back(cnt);
      }
      ++cnt;
      now.first += now.second;
      now.first %= r;
      swap(now.first, now.second);
    }
    vector<long long> ans = work(v, prd, r);
    if (ans.size() == 0) {
      printf("-1\n");
    } else {
      printf("%I64d\n", *min_element(ans.begin(), ans.end()));
    }
  }
  return 0;
}
