#include <bits/stdc++.h>
using namespace std;
const int L = 2, MAXN = 1000 + 10;
long long f, MOD = 10, TOT = 60;
vector<long long> a, b;
long long mul(long long a, long long b) {
  return (a * b - (long long)((double)a / MOD * b + 1e-7) * MOD + MOD) % MOD;
}
struct Matrix {
  long long num[L][L];
  Matrix() { memset(num, 0, sizeof(num)); }
  Matrix operator*(const Matrix &b) const {
    Matrix c;
    for (int i = 0; i < L; ++i)
      for (int j = 0; j < L; ++j)
        for (int k = 0; k < L; ++k)
          c.num[i][j] = (c.num[i][j] + mul(num[i][k], b.num[k][j])) % MOD;
    return c;
  }
};
long long fib(long long n) {
  Matrix A, B;
  if (!n) return 0;
  A.num[0][1] = 1;
  B.num[0][0] = 0, B.num[0][1] = 1, B.num[1][0] = 1, B.num[1][1] = 1;
  for (; n; A = (n & 1) ? A * B : A, B = B * B, n /= 2)
    ;
  return A.num[0][0];
}
int n;
void init() {
  cin >> f;
  for (int i = 1; i <= TOT; ++i)
    if (fib(i) == f % MOD) a.push_back(i);
}
void solve() {
  for (int i = 1; i < 13; ++i) {
    MOD *= 10, b.clear();
    for (int j = 0; j < (int)a.size(); ++j)
      for (int k = 0; k < 10; ++k)
        if (fib(k * TOT + a[j]) == f % MOD) b.push_back(k * TOT + a[j]);
    TOT *= 10;
    a = b;
  }
  if (a.size()) {
    for (int i = 1; i < (int)a.size(); ++i) a[0] = min(a[0], a[i]);
    cout << a[0] << endl;
  } else
    puts("-1");
}
int main() {
  init();
  solve();
  fclose(stdin);
  fclose(stdout);
  return 0;
}
