#include <bits/stdc++.h>
using namespace std;
vector<long long> z, q;
long long w, p = 10, l = 60;
long long mul(long long x, long long y) {
  long long z = 0;
  for (; y; y >>= 1, x = x * 2 % p)
    if (y & 1) z = (z + x) % p;
  return z;
}
pair<long long, long long> F(long long x) {
  if (x == 0) return pair<long long, long long>(0, 1);
  if (x & 1) {
    pair<long long, long long> u = F(x - 1);
    return pair<long long, long long>(u.second, (u.first + u.second) % p);
  } else {
    pair<long long, long long> u = F(x / 2);
    return pair<long long, long long>(
        mul(u.first, 2 * u.second + p - u.first),
        (mul(u.first, u.first) + mul(u.second, u.second)) % p);
  }
}
int main() {
  cin >> w;
  for (int i = 0; i < l; i++)
    if (F(i).first == w % p) z.push_back(i);
  for (int i = 0; i < 12; i++) {
    p *= 10;
    q.clear();
    for (long long j : z)
      for (int k = 0; k < 10; k++)
        if (F(j + k * l).first == w % p) q.push_back(j + k * l);
    z.swap(q);
    l *= 10;
  }
  if (!z.size())
    puts("-1");
  else
    cout << *min_element(z.begin(), z.end());
}
