#include <bits/stdc++.h>
using namespace std;
struct matrix {
  long long a[3][3];
};
struct matrix a, b, e;
long long n, mod;
long long c[20];
vector<long long> w[20];
long long mul(long long x, long long y) {
  long long tmp =
      (x * y - (long long)((long double)x / mod * y + 1.0e-8) * mod);
  return tmp < 0 ? tmp + mod : tmp;
}
matrix operator*(matrix A, matrix B) {
  matrix ret;
  int i, j, k;
  for (i = 1; i <= 2; i++)
    for (j = 1; j <= 2; j++) {
      ret.a[i][j] = 0;
      for (k = 1; k <= 2; k++)
        ret.a[i][j] = (ret.a[i][j] + mul(A.a[i][k], B.a[k][j])) % mod;
    }
  return ret;
}
matrix fpow(matrix A, long long j) {
  matrix ret = e;
  while (j > 0) {
    if (j & 1) ret = ret * A;
    A = A * A;
    j /= 2;
  }
  return ret;
}
long long calc(long long m) {
  if (m == 0) return 0;
  if (m == 1) return 1;
  b.a[1][1] = 0;
  b.a[1][2] = 1;
  b.a[2][1] = 0;
  b.a[2][2] = 0;
  b = b * fpow(a, m - 1);
  return b.a[1][2];
}
int main() {
  int i, j, k;
  cin >> n;
  e.a[1][1] = 1;
  e.a[2][2] = 1;
  a.a[1][2] = 1;
  a.a[2][1] = 1;
  a.a[2][2] = 1;
  c[1] = 60;
  c[2] = 1500;
  c[3] = 1500;
  for (i = 4; i <= 13; i++) c[i] = 10 * c[i - 1];
  mod = 1000;
  for (i = 0; i < 1500; i++)
    if (calc(i) == n % mod) w[3].push_back(i);
  for (i = 4; i <= 13; i++) {
    mod *= 10;
    for (j = 0; j < w[i - 1].size(); j++)
      for (k = 0; k <= 9; k++)
        if (calc((w[i - 1][j] + c[i - 1] * k) % c[i]) == n % mod)
          w[i].push_back((w[i - 1][j] + c[i - 1] * k) % c[i]);
  }
  sort(w[13].begin(), w[13].end());
  if (!w[13].empty())
    printf("%I64d\n", w[13][0]);
  else
    printf("-1\n");
  return 0;
}
