#include <bits/stdc++.h>
using namespace std;
unsigned long long MOD = 10000000000000ULL;
unsigned long long mul(unsigned long long a, unsigned long long b) {
  unsigned long long ret = 0;
  while (b) {
    if (b & 1) ret = (ret + a) % MOD;
    a = (a << 1) % MOD;
    b >>= 1;
  }
  return ret;
}
struct Matrix {
  unsigned long long mat[2][2];
  Matrix() { memset(mat, 0, sizeof mat); }
  inline Matrix operator*(const Matrix& b) {
    Matrix ret;
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 2; k++)
          ret.mat[i][j] += mul(mat[i][k], b.mat[k][j]);
        ret.mat[i][j] %= MOD;
      }
    return ret;
  }
};
inline unsigned long long fib(unsigned long long N) {
  N++;
  Matrix trans;
  trans.mat[0][1] = trans.mat[1][0] = trans.mat[1][1] = 1;
  Matrix unit;
  unit.mat[0][0] = unit.mat[1][1] = 1;
  while (N) {
    if (N & 1) unit = unit * trans;
    trans = trans * trans;
    N >>= 1;
  }
  return unit.mat[0][0];
}
vector<unsigned long long> pos, tmp;
int main() {
  unsigned long long x;
  cin >> x;
  if (x == 0 || x == 1) {
    cout << x << '\n';
    return 0;
  }
  unsigned long long v1 = 0, v2 = 1;
  for (int i = 2; i <= 15000000; i++) {
    unsigned long long tmp = (v1 + v2) % 10000000;
    v1 = v2, v2 = tmp;
    if (tmp % 10000000 == x % 10000000) {
      pos.push_back(i);
    }
  }
  unsigned long long ans = 0;
  unsigned long long cur_lvl = 15000000, cur_mod = 10000000;
  for (int lvlcnt = 1; lvlcnt <= 6; lvlcnt++) {
    cur_mod *= 10;
    for (int i = 1; i <= 10; i++) {
      for (int j = 0; j < (int)pos.size(); j++) {
        unsigned long long cur =
            (unsigned long long)pos[j] + (unsigned long long)(i - 1) * cur_lvl;
        if (fib(cur) % cur_mod == x % cur_mod) tmp.push_back(cur);
      }
    }
    cur_lvl *= 10;
    pos.swap(tmp);
    tmp.clear();
  }
  if (pos.size() == 0)
    puts("-1");
  else
    cout << pos[0] << '\n';
}
