#include #include #include using namespace std; int main() { long long N; cin >> N; for (int k = 2; k <= 70; ++k) { vector<__int128> vs(k + 1); vs.back() = 1; while (vs.back() < N) { __int128 sum = std::accumulate(vs.end() - k, vs.end(), __int128(0)); vs.push_back(sum); } if (vs.back() == N) { cout << k << '\n'; return 0; } } puts("-1"); }