#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
struct Matrix {
  int n, m;
  long long a[2][2];
  Matrix() {}
  Matrix(int n, int m) : n(n), m(m) {}
  void init(long long num) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) a[i][j] = num;
  }
  long long mult(long long a, long long b) {
    long long tmp = (a * b - (long long)((long double)a * b / 10000000000000) *
                                 10000000000000) %
                    10000000000000;
    return tmp < 0 ? tmp + 10000000000000 : tmp;
  }
  Matrix operator*(Matrix b) {
    Matrix o = Matrix(n, b.m);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < b.m; j++) {
        o.a[i][j] = 0;
        for (int k = 0; k < m; k++) {
          o.a[i][j] = (o.a[i][j] + mult(a[i][k], b.a[k][j]) % 10000000000000) %
                      10000000000000;
        }
      }
    }
    return o;
  }
  Matrix pow(long long p) {
    Matrix o = Matrix(n, m);
    Matrix b = *this;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) o.a[i][j] = (i == j);
    while (p > 0) {
      if (p & 1) o = o * b;
      b = b * b;
      p >>= 1;
    }
    return o;
  }
};
long long F;
long long f[15000005], pos[15];
Matrix mm[15];
int main() {
  scanf("%lld", &F);
  Matrix mat = Matrix(2, 2);
  mat.init(1);
  mat.a[1][1] = 0;
  f[1] = 1;
  int cnt = 0;
  for (int i = 0; i <= 15000000; i++) {
    if (i > 1) f[i] = (f[i - 1] + f[i - 2]) % 10000000;
    if (f[i] == F % 10000000) {
      mm[++cnt] = mat.pow(i);
      pos[cnt] = i;
    }
  }
  mat = mat.pow(15000000);
  for (int i = 0; i <= 1000000; i++) {
    for (int j = 1; j <= cnt; j++) {
      if (mm[j].a[0][1] == F) {
        printf("%lld\n", pos[j]);
        return 0;
      }
      pos[j] += 15000000;
      mm[j] = mm[j] * mat;
    }
  }
  puts("-1");
  return 0;
}
