#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > Multiply(const vector<vector<long long> >& a,
                                    const vector<vector<long long> >& b,
                                    int modulo) {
  vector<vector<long long> > c(a.size(), vector<long long>(a.size(), 0));
  for (int i = 0; i < a.size(); ++i) {
    for (int j = 0; j < a.size(); ++j) {
      for (int k = 0; k < a.size(); ++k) {
        c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % modulo;
      }
    }
  }
  return c;
}
vector<vector<long long> > MyPow(const vector<vector<long long> >& a,
                                 long long n, int modulo) {
  if (n == 1) {
    return a;
  }
  vector<vector<long long> > tmp = MyPow(a, n / 2, modulo);
  vector<vector<long long> > res = Multiply(tmp, tmp, modulo);
  if (n % 2) {
    return Multiply(res, a, modulo);
  } else {
    return res;
  }
}
int GetFibRemainder(long long num, int modulo) {
  if (num == 0) {
    return 0;
  } else if (num == 1) {
    return 1 % modulo;
  } else {
    vector<vector<long long> > a(2, vector<long long>(2));
    a[0][1] = 1;
    a[1][0] = 1;
    a[1][1] = 1;
    a = MyPow(a, num, modulo);
    return a[0][1];
  }
}
vector<pair<long long, long long> > FindPeriod(int mod_base, int pow_base) {
  int base = 1;
  long long start_period = 0;
  long long length_period = 1;
  vector<pair<long long, long long> > result;
  for (int i = 1; i <= pow_base; ++i) {
    base *= mod_base;
    vector<pair<int, int> > rems;
    rems.push_back(make_pair(GetFibRemainder(start_period, base),
                             GetFibRemainder(start_period + 1, base)));
    long long cur_start_period = start_period;
    while (true) {
      cur_start_period += length_period;
      pair<int, int> new_pair =
          make_pair(GetFibRemainder(cur_start_period, base),
                    GetFibRemainder(cur_start_period + 1, base));
      bool found_period = false;
      for (int j = 0; j < rems.size(); ++j) {
        if (new_pair == rems[j]) {
          start_period += j * length_period;
          length_period = (rems.size() - j) * length_period;
          found_period = true;
          break;
        }
      }
      if (found_period) {
        break;
      }
      rems.push_back(new_pair);
    }
    result.push_back(make_pair(start_period, length_period));
  }
  return result;
}
vector<long long> FindPos(long long f, int base,
                          const vector<pair<long long, long long> >& periods) {
  vector<long long> positions;
  for (int i = 0; i < periods[0].first + periods[0].second; ++i) {
    if (f % base == GetFibRemainder(i, base)) {
      positions.push_back(i);
    }
  }
  if (positions.empty()) {
    return vector<long long>();
  }
  int cur_base = base;
  for (int i = 1; i < periods.size(); ++i) {
    cur_base *= base;
    vector<long long> new_positions;
    for (int j = 0; j < positions.size(); ++j) {
      for (long long pos = positions[j];
           pos < periods[i].first + periods[i].second;
           pos += periods[i - 1].second) {
        if (f % cur_base == GetFibRemainder(pos, cur_base)) {
          new_positions.push_back(pos);
        }
      }
    }
    if (new_positions.empty()) {
      return vector<long long>();
    }
    sort(new_positions.begin(), new_positions.end());
    new_positions.erase(unique(new_positions.begin(), new_positions.end()),
                        new_positions.end());
    swap(positions, new_positions);
  }
  return positions;
}
int main() {
  vector<pair<long long, long long> > base_2 = FindPeriod(2, 13);
  vector<pair<long long, long long> > base_5 = FindPeriod(5, 13);
  long long f;
  cin >> f;
  vector<long long> pos_mod_2 = FindPos(f, 2, base_2);
  vector<long long> pos_mod_5 = FindPos(f, 5, base_5);
  if (pos_mod_2.empty() || pos_mod_5.empty()) {
    cout << -1 << endl;
    return 0;
  }
  long long min_ans = numeric_limits<long long>::max();
  for (int i = 0; i < pos_mod_2.size(); ++i) {
    for (int j = 0; j < pos_mod_5.size(); ++j) {
      for (int k = 0; k < base_2.back().second; ++k) {
        long long position = pos_mod_5[j] + k * base_5.back().second;
        if (position % base_2.back().second == pos_mod_2[i]) {
          min_ans = min(min_ans, position);
        }
      }
    }
  }
  if (min_ans == numeric_limits<long long>::max()) {
    cout << -1 << endl;
  } else {
    cout << min_ans << endl;
  }
  return 0;
}
