#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline long long ty() {
  long long a = 0;
  int b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
const long long mo = 10000000000000;
template <typename T1, typename T2>
inline T1 ad(T1 &a, T2 b) {
  return a = a + b >= mo ? a + b - mo : a + b;
}
template <typename T1, typename T2>
inline T1 dl(T1 &a, T2 b) {
  return a = a >= b ? a - b : a - b + mo;
}
template <typename T1, typename T2>
inline T1 add(T1 a, T2 b) {
  return a + b >= mo ? a + b - mo : a + b;
}
template <typename T1, typename T2>
inline T1 del(T1 a, T2 b) {
  return a >= b ? a - b : a - b + mo;
}
inline long long sfx(long long a, long long b) {
  long long c = 0;
  while (b) {
    if (b & 1) ad(c, a);
    ad(a, a), b >>= 1;
  }
  return c;
}
template <typename T1, typename T2>
inline T1 xm(T1 &a, T2 b) {
  return a = sfx(a, b);
}
long long powa(long long a, long long t) {
  long long b = 1;
  while (t) {
    if (t & 1) xm(b, a);
    xm(a, a), t >>= 1;
  }
  return b;
}
const int M = 2;
struct martix {
  long long val[M][M];
  martix() { memset(val, 0, sizeof(val)); }
  void be1() {
    memset(val, 0, sizeof(val));
    for (int i = 0; i < M; i++) val[i][i] = 1;
  }
  long long *operator[](int x) { return val[x]; }
  friend martix operator*(martix a, martix b) {
    martix c;
    for (int i = 0; i < M; i++)
      for (int j = 0; j < M; j++)
        for (int k = 0; k < M; k++) ad(c[i][j], sfx(a[i][k], b[k][j]));
    return c;
  }
};
martix powa(martix a, long long t) {
  martix b;
  b.be1();
  while (t) {
    if (t & 1) b = b * a;
    a = a * a, t >>= 1;
  }
  return b;
}
inline long long fibna(long long x) {
  martix tran;
  tran[0][0] = tran[0][1] = tran[1][0] = 1;
  return powa(tran, x)[0][1];
}
long long ans;
void dfs(long long now, long long tar, long long p, long long loc) {
  if (fibna(now) == tar) {
    ans = min(ans, now);
    return;
  }
  for (int i = 0; i <= 9; i++)
    if (tar % p == fibna(loc * i + now) % p)
      dfs(loc * i + now, tar, p * 10, loc * 10);
}
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  long long n = ty();
  ans = 9e18;
  for (int i = 1; i <= 1500; i++)
    if (n % 1000 == fibna(i) % 1000) dfs(i, n, 10000, 1500);
  if (ans >= 9e18) ans = -1;
  cout << ans << lf;
  return 0;
}
