#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > a;
vector<vector<long long> > vec(long long a, long long b, long long c,
                               long long d) {
  vector<vector<long long> > res;
  vector<long long> z(2);
  z[0] = a, z[1] = b;
  res.push_back(z);
  z[0] = c, z[1] = d;
  res.push_back(z);
  return res;
}
long long calc(long long x, long long y) {
  long long a = x / 10000000, b = x % 10000000;
  long long c = y / 10000000, d = y % 10000000;
  long long res =
      (((a * d + b * c) % 1000000) * 10000000 + b * d) % 10000000000000;
  return res;
}
vector<vector<long long> > mult(vector<vector<long long> > a,
                                vector<vector<long long> > b) {
  int i, j, k;
  vector<vector<long long> > res = vec(0, 0, 0, 0);
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      for (k = 0; k < 2; k++) {
        res[i][j] += calc(a[i][k], b[k][j]);
        if (res[i][j] > 10000000000000) res[i][j] %= 10000000000000;
      }
    }
  }
  return res;
}
vector<vector<long long> > pow_(vector<vector<long long> > a, long long n) {
  vector<vector<long long> > res = vec(1, 0, 0, 1);
  while (n > 0) {
    if (n % 2 == 1) {
      res = mult(res, a);
    }
    a = mult(a, a);
    n /= 2;
  }
  return res;
}
long long n;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n;
  if (n == 0) return 0;
  a = vec(1, 1, 1, 0);
  vector<vector<long long> > b;
  vector<long long> v;
  long long e = n % 10;
  long long prev = -1;
  long long p;
  long long mo = 10;
  int i;
  for (i = 0; i < 100; i++) {
    b = pow_(a, i);
    if (b[0][0] % mo == e) {
      v.push_back(i);
    }
    if (b[0][0] % mo == 1 && prev == 0) {
      p = i;
      break;
    }
    prev = b[0][0] % mo;
  }
  while (v[v.size() - 1] > i - 2) v.pop_back();
  mo *= 10;
  long long x;
  vector<long long> u = v;
  vector<long long>().swap(v);
  while (mo <= 10000000000000) {
    e = n % mo;
    x = 0;
    while (true) {
      for (auto z : u) {
        if (pow_(a, z + (x)*p)[0][0] % mo == e) v.push_back(z + (x)*p);
      }
      x++;
      if (pow_(a, x * p)[0][0] % mo == 1 &&
          pow_(a, x * p - 1)[0][0] % mo == 0) {
        break;
      }
    }
    u = v;
    vector<long long>().swap(v);
    p = x * p;
    mo *= 10;
  }
  if (u.size() == 0)
    cout << -1 << endl;
  else
    cout << u[0] + 1 << endl;
  return 0;
}
