#include <bits/stdc++.h>
using namespace std;
long long x, off = 10;
vector<long long> vec[15];
inline long long mul(long long a, long long b) {
  bool neg = false;
  long long res = 0;
  if (b < 0) {
    neg = true;
    b = -b;
  }
  while (b) {
    if (b & 1) res = (res + a) % off;
    a = (a + a) % off;
    b >>= 1;
  }
  return neg ? (off - res) % off : res;
}
inline pair<long long, long long> fib(long long n) {
  if (!n) return make_pair(0, 1);
  if (n & 1) {
    pair<long long, long long> res = fib(n - 1);
    return make_pair(res.second, (res.first + res.second) % off);
  }
  pair<long long, long long> res = fib(n >> 1);
  return make_pair(
      mul(res.first, 2 * res.second - res.first),
      (mul(res.first, res.first) + mul(res.second, res.second)) % off);
}
int main() {
  scanf("%lld", &x);
  for (int i = 0; i < 60; i++) {
    if (fib(i).first == x % off) vec[0].push_back(i);
  }
  long long step = 60;
  for (int i = 0; i < 12; i++) {
    off *= 10;
    for (long long y : vec[i]) {
      for (int j = 0; j < 10; j++) {
        if (fib(y + j * step).first == x % off)
          vec[i + 1].push_back(y + j * step);
      }
    }
    step *= 10;
  }
  if (!vec[12].size())
    printf("-1\n");
  else
    printf("%lld\n", *min_element(vec[12].begin(), vec[12].end()));
  return 0;
}
