#include <bits/stdc++.h>
const long long oo = 10000000000000ll;
const long long oo1 = 8192;
const long long oo2 = 1953125;
const long long p = 24000000000ll;
const long long p1 = 12288;
const long long p2 = 7812500;
const long long E[2][2] = {{0, 1}, {1, 1}};
long long Ans, N, i, j, Cnt1, Cnt2, Cnt, X, Y, Gcd, W, X1, Y1, Xx, Yy, G;
long long f[p2];
long long Q[1000], D[1000][2], Q1[1000], Q2[1000];
long long a[2], A[2], b[2][2], B[2][2], C[2][2];
long long Abs(long long a) {
  if (a < 0) return -a;
  return a;
}
long long Ex_gcd(long long a, long long b, long long &X, long long &Y) {
  long long Gcd, t;
  if (!b) {
    X = 1, Y = 0;
    return a;
  }
  Gcd = Ex_gcd(b, a % b, X, Y);
  t = X, X = Y, Y = t - (a / b) * Y;
  return Gcd;
}
long long Get(long long A, long long B) {
  long long A1 = A % 100000, A2 = A / 100000;
  long long B1 = B % 100000, B2 = B / 100000;
  long long S1 = A2 * B2 % oo;
  long long S2 = (A1 * B2 + A2 * B1) % oo;
  long long S3 = A1 * B1 % oo;
  long long S = 0;
  S = S1;
  S = S * 100000 % oo;
  S = (S + S2) % oo;
  S = S * 100000 % oo;
  S = (S + S3) % oo;
  return S;
}
void Mul1() {
  int i, j;
  memset(a, 0, sizeof(a));
  for (i = 0; i < 2; ++i)
    if (A[i])
      for (j = 0; j < 2; ++j)
        if (B[i][j]) a[j] = (a[j] + Get(A[i], B[i][j])) % oo;
  memcpy(A, a, sizeof(A));
}
void Mul2() {
  int i, j, k;
  memset(b, 0, sizeof(b));
  for (i = 0; i < 2; ++i)
    for (j = 0; j < 2; ++j)
      if (B[i][j])
        for (k = 0; k < 2; ++k)
          if (B[j][k]) b[i][k] = (b[i][k] + Get(B[i][j], B[j][k])) % oo;
  memcpy(B, b, sizeof(B));
}
void Mul3() {
  int i, j, k;
  memset(b, 0, sizeof(b));
  for (i = 0; i < 2; ++i)
    for (j = 0; j < 2; ++j)
      if (C[i][j])
        for (k = 0; k < 2; ++k)
          if (B[j][k]) b[i][k] = (b[i][k] + Get(C[i][j], B[j][k])) % oo;
  memcpy(C, b, sizeof(C));
}
void Mul(long long N) {
  for (; N;) {
    if (N & 1) Mul1();
    Mul2(), N /= 2;
  }
}
void mul(long long N) {
  for (; N;) {
    if (N & 1) Mul3();
    Mul2(), N /= 2;
  }
}
int main() {
  scanf("%I64d", &N);
  f[0] = 0, f[1] = 1;
  for (i = 2; i < p1; ++i) f[i] = (f[i - 1] + f[i - 2]) % oo1;
  for (i = 0; i < p1; ++i)
    if (f[i] == N % oo1) Q1[++Cnt1] = i;
  f[0] = 0, f[1] = 1;
  for (i = 2; i < p2; ++i) f[i] = (f[i - 1] + f[i - 2]) % oo2;
  for (i = 0; i < p2; ++i)
    if (f[i] == N % oo2) Q2[++Cnt2] = i;
  Gcd = Ex_gcd(p1, p2, X, Y);
  Y = -Y;
  Xx = p2 / Gcd, Yy = p1 / Gcd;
  for (i = 1; i <= Cnt1; ++i)
    for (j = 1; j <= Cnt2; ++j)
      if ((Q2[j] - Q1[i]) % 4 == 0) {
        W = (Q2[j] - Q1[i]) / 4;
        X1 = X * W, Y1 = Y * W;
        G = X1 / Xx;
        if (Abs(Y1 / Yy) < Abs(G)) G = Y1 / Yy;
        X1 -= G * Xx, Y1 -= G * Yy;
        if (X1 < 0 || Y1 < 0) X1 += Xx, Y1 += Yy;
        Q[++Cnt] = Q1[i] + X1 * p1;
      }
  if (Cnt == 0) {
    printf("-1\n");
    return 0;
  }
  for (i = 1; i <= Cnt; ++i) {
    A[0] = 0, A[1] = 1;
    memcpy(B, E, sizeof(B));
    Mul(Q[i]);
    memcpy(D[i], A, sizeof(D[i]));
  }
  C[0][0] = C[1][1] = 1;
  memcpy(B, E, sizeof(B));
  mul(p);
  memcpy(B, C, sizeof(B));
  Ans = -1;
  for (; Ans == -1;) {
    for (i = 1; i <= Cnt; ++i)
      if (D[i][0] == N)
        if (Q[i] < Ans || Ans == -1) Ans = Q[i];
    for (i = 1; i <= Cnt; ++i) {
      memcpy(A, D[i], sizeof(A));
      Mul1();
      memcpy(D[i], A, sizeof(D[i]));
      Q[i] += p;
    }
  }
  printf("%I64d\n", Ans);
  return 0;
}
