#include <bits/stdc++.h>
const int N = 100000;
long long x, mu, cir;
long long A[N], B[N];
int cnt, tot;
void reduce(long long &x) { x += x >> 63 & mu; }
long long mul(long long x, long long y) {
  long long ret = 0;
  for (; y; y >>= 1) {
    if (y & 1) reduce(ret += x - mu);
    reduce(x = x + x - mu);
  }
  return ret;
}
struct Mat {
  long long a[2][2];
  void mem() { memset(a, 0, sizeof(a)); }
  friend Mat operator*(Mat a, Mat b) {
    Mat ret;
    ret.mem();
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          reduce(ret.a[i][j] += mul(a.a[i][k], b.a[k][j]) - mu);
    return ret;
  }
} tran;
struct note {
  long long a[2];
  void mem() { a[0] = a[1] = 0; }
  friend note operator*(note a, Mat b) {
    note ret;
    ret.mem();
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        reduce(ret.a[j] += mul(a.a[i], b.a[i][j]) - mu);
    return ret;
  }
};
long long ksm(long long y) {
  y--;
  note ans;
  Mat x = tran;
  ans.a[0] = 1, ans.a[1] = 0;
  for (; y; y >>= 1, x = x * x)
    if (y & 1) ans = ans * x;
  return ans.a[0];
}
int main() {
  scanf("%lld", &x);
  tran.a[0][0] = 1;
  tran.a[0][1] = 1;
  tran.a[1][0] = 1;
  tran.a[1][1] = 0;
  long long a = 0, b = 1;
  mu = 1000, cir = 1500;
  for (int i = 1, st = x % mu; i <= cir; i++) {
    if (b == st) A[++cnt] = i;
    long long c;
    reduce(c = a + b - mu);
    a = b, b = c;
  }
  for (mu = mu * 10; mu <= (1e13); mu = mu * 10, cir = cir * 10) {
    long long st = x % mu;
    int tot = 0;
    for (int t = 0; t <= 9; t++) {
      for (int i = 1; i <= cnt; i++)
        if (ksm(A[i] + t * cir) == st) B[++tot] = A[i] + t * cir;
    }
    for (int i = 1; i <= tot; i++) A[i] = B[i];
    cnt = tot;
  }
  if (!cnt) return puts("-1"), 0;
  printf("%lld\n", A[1]);
}
