#include <bits/stdc++.h>
using namespace std;
long long mod;
struct mat {
  const static int size = 2;
  long long v[size][size];
  void create();
  void clear();
  mat operator*(const mat &b);
  mat operator^(long long k);
} E, A, C;
inline void mat::create() {
  memset(v, 0, sizeof(v));
  for (int i = 0; i < size; ++i) v[i][i] = 1;
}
inline void mat::clear() { memset(v, 0, sizeof(v)); }
inline long long mul(long long a, long long b) {
  if (mod < 1000000000) return (a * b) % mod;
  if (a == 0 || b == 0) return 0;
  long long r = 0;
  while (b) {
    if (b & 1) r = (r + a) % mod;
    b >>= 1;
    a = (a + a) % mod;
  }
  return r;
}
mat mat::operator*(const mat &b) {
  mat c;
  c.clear();
  for (int i = 0; i < size; ++i)
    for (int j = 0; j < size; ++j)
      for (int k = 0; k < size; ++k)
        c.v[i][j] = (c.v[i][j] + mul(v[i][k], b.v[k][j])) % mod;
  return c;
}
mat mat::operator^(long long k) {
  mat p = A, t = E;
  while (k) {
    if (k & 1) t = t * p;
    p = p * p;
    k >>= 1;
  }
  return t;
}
long long fib(long long k) {
  E.create();
  A.v[0][0] = 1;
  A.v[0][1] = 1;
  A.v[1][0] = 1;
  A.v[1][1] = 0;
  C = A ^ k;
  return C.v[0][1] % mod;
}
vector<long long> ans[2];
int main() {
  vector<long long> MD;
  MD.push_back(1);
  MD.push_back(60);
  MD.push_back(300);
  MD.push_back(1500);
  long long t = 1500;
  for (int i = 4; i <= 13; i++) t *= 10, MD.push_back(t);
  long long f;
  cin >> f;
  if (f == 0 || f == 1) {
    cout << f << endl;
    return 0;
  }
  int num[20] = {0}, len = 0;
  for (; f; f /= 10) num[len++] = f % 10;
  long long B[15], key = 0;
  B[0] = 1;
  for (int i = 1; i <= 13; i++) B[i] = B[i - 1] * 10;
  int k = 0, flag = 1;
  for (int i = 1; i <= 13; i++) {
    k ^= 1;
    key = key + B[i - 1] * num[i - 1];
    ans[k].clear();
    if (i == 1) {
      long long a = 0, b = 1, c;
      for (int j = 2; j <= MD[i]; j++) {
        c = (a + b) % B[i];
        if (c == key) ans[k].push_back(j);
        a = b;
        b = c;
      }
    } else {
      mod = B[i];
      for (vector<long long>::iterator it = ans[!k].begin();
           it != ans[!k].end(); ++it) {
        for (long long j = *it; j <= MD[i]; j += MD[i - 1]) {
          if (fib(j) == key) ans[k].push_back(j);
          ;
        }
      }
    }
    if (ans[k].size() == 0) {
      flag = 0;
      break;
    }
    sort(ans[k].begin(), ans[k].end());
  }
  if (!flag)
    puts("-1");
  else
    cout << ans[k][0] << endl;
  return 0;
}
