#include <bits/stdc++.h>
using namespace std;
const long long A = 1 << 13;
const long long B = 1953125;
const long long Mo = 10000000000000LL;
int a, b, c, i, j, pb, pa, mark;
long long A_[100100], B_[10000100];
long long x, Ans = 1LL << 60;
long long x_ = 1232783, y_ = 5831, Ac, Bc, Cc;
int X[110], Y[110], topx, topy;
long long gcd(long long a, long long b) { return (b ? gcd(b, a % b) : a); }
long long lcm(long long a, long long b) { return (a * b / gcd(a, b)); }
void init() {
  for (A_[1] = 1, i = 2;
       (A_[i] = (A_[i - 1] + A_[i - 2]) % A) || (A_[i - 1] != 1 && i > 10); i++)
    ;
  Ac = i;
  for (B_[1] = 1, i = 2;
       (B_[i] = (B_[i - 1] + B_[i - 2]) % B) || (B_[i - 1] != 1 && i > 10); i++)
    ;
  Bc = i;
  Cc = lcm(Ac, Bc);
}
long long mul(long long a, long long b) {
  long long ans = 0;
  for (; b; b >>= 1) {
    if (b & 1) (ans += a) %= Mo;
    (a += a) %= Mo;
  }
  return ans;
}
struct matrix {
  long long v[2][2];
  void operator*=(matrix b) {
    matrix a;
    memcpy(a.v, v, sizeof(v));
    memset(v, 0, sizeof(v));
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          (v[i][j] += mul(a.v[i][k], b.v[k][j])) %= Mo;
  }
} mat, ans;
bool judge(long long x_) {
  mat.v[0][0] = 0;
  mat.v[0][1] = mat.v[1][1] = mat.v[1][0] = 1;
  ans.v[0][0] = ans.v[1][1] = 1;
  ans.v[1][0] = ans.v[0][1] = 0;
  for (; x_; x_ >>= 1) {
    if (x_ & 1) ans *= mat;
    mat *= mat;
  }
  return (ans.v[1][0] == x);
}
bool Judge(long long pa, long long pb) {
  long long x, y = 0;
  for (y = 0; y < Ac; y++)
    if (((y * Bc + pb - pa) % Ac) || (y * Bc + pb - pa) / Ac < 0)
      continue;
    else
      break;
  if (y == Ac) return false;
  x = y * Bc + pb;
  for (; ((1LL << 50) - 1LL) - Cc > x; x += Cc)
    if (judge(x)) {
      Ans = min(Ans, x);
      return true;
    }
  return false;
}
int main() {
  init();
  cin >> x;
  topx = 0;
  topy = 0;
  for (i = 0; i < (int)Ac; i++)
    if (A_[i] == x % A) X[++topx] = i;
  for (i = 0; i < (int)Bc; i++)
    if (B_[i] == x % B) Y[++topy] = i;
  for (i = 1; i <= topx; i++)
    for (j = 1; j <= topy; j++)
      if (mark |= Judge(X[i], Y[j]))
        ;
  if (mark)
    cout << Ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
