#include <bits/stdc++.h>
using namespace std;
long long mult(long long a, long long b, long long m) {
  long long ret = 0;
  for (long long i = 1; i <= b; i *= 2, a = a * 2 % m)
    if (b & i) ret = (ret + a) % m;
  return ret;
}
struct mat {
  long long T[2][2];
  void O() { memset(T, 0, sizeof(T)); }
  void I() {
    O();
    for (int i = 0; i < 2; i++) T[i][i] = 1;
  }
};
mat mult(mat a, mat b, long long m) {
  mat ret;
  ret.O();
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        ret.T[i][j] += mult(a.T[i][k], b.T[k][j], m);
        ret.T[i][j] %= m;
      }
    }
  }
  return ret;
}
mat exp(mat x, long long n, long long m) {
  mat ret;
  ret.I();
  while (n) {
    if (n & 1) ret = mult(ret, x, m);
    x = mult(x, x, m);
    n >>= 1;
  }
  return ret;
}
mat A, B;
long long calc(long long x, long long m) {
  A.O();
  B.O();
  A.T[0][0] = 1, A.T[0][1] = 1, A.T[1][0] = 1;
  B.T[0][0] = 1;
  return mult(exp(A, x, m), B, m).T[1][0];
}
long long r, p = 10, d = 60;
long long fibo[62];
vector<long long> X[14];
int main() {
  fibo[0] = 0;
  fibo[1] = 1;
  for (int i = 2; i < 62; i++) {
    fibo[i] = fibo[i - 1] + fibo[i - 2];
  }
  cin >> r;
  for (int i = 0; i < 60; i++) {
    if (fibo[i] % 10 == r % 10) X[1].push_back(i);
  }
  for (int i = 2; i <= 13; i++) {
    p *= 10;
    for (int j = 0; j < X[i - 1].size(); j++) {
      for (int k = 0; k < 10; k++) {
        if (calc(X[i - 1][j] + d * k, p) == r % p) {
          X[i].push_back(X[i - 1][j] + d * k);
        }
      }
    }
    d *= 10;
  }
  sort(X[13].begin(), X[13].end());
  if (X[13].size() == 0)
    printf("-1");
  else
    printf("%lld", X[13][0]);
}
