#include <bits/stdc++.h>
using namespace std;
struct Mat {
  long long d[4];
};
long long mul(const long long &a, const long long &b, const long long &mod) {
  long long ans = 0, base = b;
  for (long long t = a; t != 0; t >>= 1) {
    if (t & 1) ans = (ans + base) % mod;
    base = (base << 1) % mod;
  }
  return ans;
}
Mat t;
void multiply(Mat &a, const Mat &b, long long mod) {
  t.d[0] = (mul(a.d[0], b.d[0], mod) + mul(a.d[1], b.d[2], mod)) % mod;
  t.d[1] = (mul(a.d[0], b.d[1], mod) + mul(a.d[1], b.d[3], mod)) % mod;
  t.d[2] = (mul(a.d[2], b.d[0], mod) + mul(a.d[3], b.d[2], mod)) % mod;
  t.d[3] = (mul(a.d[2], b.d[1], mod) + mul(a.d[3], b.d[3], mod)) % mod;
  a = t;
}
Mat Munit, Mtrans;
Mat power(const Mat &base, long long times, long long mod) {
  Mat ans = Munit, pow = base;
  for (; times; times >>= 1) {
    if (times & 1) multiply(ans, pow, mod);
    multiply(pow, pow, mod);
  }
  return ans;
}
bool operator==(const Mat &a, const Mat &b) {
  return memcmp(a.d, b.d, sizeof(a.d)) == 0;
}
const long long mod = 1e13;
int main() {
  Munit.d[0] = Munit.d[3] = 1;
  Munit.d[1] = Munit.d[2] = 0;
  Mtrans.d[0] = Mtrans.d[1] = Mtrans.d[2] = 1;
  Mtrans.d[3] = 0;
  long long x;
  cin >> x;
  vector<long long> pre, cur;
  long long mul = 10, p = 1;
  pre.push_back(0);
  for (; mul <= mod; mul *= 10) {
    Mat pow = power(Mtrans, p, mul), res = pow;
    long long np = p;
    for (; !(res == Munit); np += p) multiply(res, pow, mul);
    cur.clear();
    for (vector<long long>::iterator i = pre.begin(); i != pre.end(); i++) {
      Mat Mi = power(Mtrans, *i, mul);
      for (long long v = *i; v < np; v += p) {
        if (Mi.d[2] == x % mul) cur.push_back(v);
        multiply(Mi, pow, mul);
      }
    }
    p = np;
    pre.swap(cur);
  }
  if (pre.empty())
    puts("-1");
  else {
    long long ans = *pre.begin();
    for (vector<long long>::iterator i = pre.begin(); i != pre.end(); i++)
      ans = min(ans, *i);
    cout << ans << endl;
  }
  return 0;
}
