#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const int INF = ((1 << 30) - 1);
const long long LLINF = (((1LL << 60) - 1LL));
const double EPS = 1e-9;
const double PI = 3.14159265358979323846;
long long check(long long x, long long mod) { return ((x % mod) + mod) % mod; }
long long mulNumbers(long long a, long long b, long long mod) {
  long long res = 0;
  while (b) {
    if (b & 1) {
      res = check(res + a, mod);
    }
    a = check(a + a, mod);
    b >>= 1;
  }
  return res;
}
vector<vector<long long> > mul(const vector<vector<long long> >& a,
                               const vector<vector<long long> >& b,
                               long long mod) {
  vector<vector<long long> > res(2, vector<long long>(2));
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      for (int k = 0; k < 2; ++k) {
        long long prod = mulNumbers(a[i][k], b[k][j], mod);
        res[i][j] = check(res[i][j] + prod, mod);
      }
    }
  }
  return res;
}
vector<vector<long long> > toPower(vector<vector<long long> > M,
                                   long long exponent, long long mod) {
  vector<vector<long long> > res(2, vector<long long>(2));
  res[0][0] = res[1][1] = check(1, mod);
  while (exponent) {
    if (exponent & 1) {
      res = mul(res, M, mod);
    }
    M = mul(M, M, mod);
    exponent >>= 1;
  }
  return res;
}
long long getRemain(long long index, long long mod) {
  vector<vector<long long> > M(2, vector<long long>(2, check(1, mod)));
  M[0][0] = 0;
  vector<vector<long long> > Mpower = toPower(M, index, mod);
  long long res = Mpower[0][1];
  return res;
}
int main() {
  long long remain;
  cin >> remain;
  long long curPeriod = 1;
  long long curPower10 = 1;
  vector<long long> curRemain(1, 0);
  for (long long it = 1; it <= 13; ++it) {
    cerr << "curPeriod"
         << ": " << curPeriod << endl;
    ;
    for (int i = 0; i < curRemain.size(); ++i) {
      cerr << curRemain[i] << " ";
    }
    cerr << endl;
    long long nextPeriodMul;
    for (long long m = 1;; ++m) {
      long long a = getRemain(curPeriod * m, curPower10 * 10);
      long long b = getRemain(curPeriod * m + 1, curPower10 * 10);
      if (a == 0 && b == 1) {
        nextPeriodMul = m;
        break;
      }
    }
    long long nextPeriod = curPeriod * nextPeriodMul;
    long long needSteps = -1;
    vector<long long> nextRemain;
    for (int ID = 0; ID < curRemain.size(); ++ID) {
      for (long long steps = 0; steps < nextPeriodMul; ++steps) {
        if (getRemain(curPeriod * steps + curRemain[ID], curPower10 * 10) ==
            check(remain, curPower10 * 10)) {
          nextRemain.push_back(curPeriod * steps + curRemain[ID]);
        }
      }
    }
    curPower10 *= 10;
    curPeriod = nextPeriod;
    curRemain = nextRemain;
  }
  cout << (curRemain.empty()
               ? -1
               : *min_element((curRemain).begin(), (curRemain).end()))
       << endl;
  return 0;
}
