#include <bits/stdc++.h>
using namespace std;
namespace IO {
const int sz = 1 << 15;
char inbuf[sz], outbuf[sz];
char *pinbuf = inbuf + sz;
char *poutbuf = outbuf;
inline char _getchar() {
  if (pinbuf == inbuf + sz) fread(inbuf, 1, sz, stdin), pinbuf = inbuf;
  return *(pinbuf++);
}
inline void _putchar(char x) {
  if (poutbuf == outbuf + sz) fwrite(outbuf, 1, sz, stdout), poutbuf = outbuf;
  *(poutbuf++) = x;
}
inline void flush() {
  if (poutbuf != outbuf)
    fwrite(outbuf, 1, poutbuf - outbuf, stdout), poutbuf = outbuf;
}
}  // namespace IO
inline int read() {
  int v = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    v = v * 10 + c - '0';
    c = getchar();
  }
  return v * f;
}
const long long mod = 1e13;
struct mat {
  long long A[2][2];
  int x, y;
  mat(int _x = 0, int _y = 0) {
    x = _x, y = _y;
    memset(A, 0, sizeof(A));
  }
};
mat mul(mat x, mat y) {
  mat z(x.x, y.y);
  for (int i = 0; i < x.x; i++) {
    for (int j = 0; j < y.y; j++) {
      __int128 tmp = 0;
      for (int k = 0; k < x.y; k++) {
        tmp += (__int128)x.A[i][k] * y.A[k][j];
        tmp %= (__int128)mod;
      }
      z.A[i][j] = tmp;
    }
  }
  return z;
}
mat Qp(mat x, long long p) {
  mat ret(x.x, x.x);
  for (int i = 0; i < x.x; i++) ret.A[i][i] = 1;
  while (p) {
    if (p & 1) ret = mul(ret, x);
    p >>= 1;
    x = mul(x, x);
  }
  return ret;
}
long long FIB(long long n) {
  mat V(2, 2);
  V.A[0][0] = V.A[0][1] = V.A[1][0] = 1;
  V = Qp(V, n - 1);
  return V.A[0][0];
}
const int D = 15000000;
int f[15000007];
long long F;
long long Ans = 1e18;
long long test(long long m) {
  mat V(2, 2);
  V.A[0][0] = V.A[0][1] = V.A[1][0] = 1;
  mat tmp = Qp(V, m - 1);
  mat Mul = Qp(V, D);
  for (int i = 0; i <= 10000000; i++) {
    long long t = 1ll * i * D + m;
    if (t >= 15000000000000LL || t > Ans) break;
    if (tmp.A[0][0] == F) {
      return 1ll * i * D + m;
    }
    tmp = mul(tmp, Mul);
  }
  return 1e18;
}
int main() {
  cin >> F;
  long long t = F % 10000000;
  f[0] = 0;
  f[1] = 1;
  for (int i = 2; i < D + 7; i++) {
    f[i] = (f[i - 1] + f[i - 2]);
    if (f[i] >= 10000000) f[i] -= 10000000;
  }
  for (int i = 0; i < D; i++) {
    if (f[i] == t) {
      Ans = min(Ans, test(i));
    }
  }
  if (Ans == 1e18) {
    printf("-1\n");
    return 0;
  }
  printf("%lld\n", Ans);
  return 0;
}
