#include using ll = long long; using namespace std; int main() { ll n; cin >> n; for (int k = 2; k < 64; k++) { vector a(k, 0); a.back() = 1; for (int i = k;; i++) { ll t = 0; for (int j = i - k; j < i; j++) { t += a[j]; } if (t == n) { cout << k << endl; exit(0); } if (t > n) break; a.push_back(t); } } cout << -1 << endl; return 0; }