typedef long long ll; typedef long double ld; #include using namespace std; #define int long long signed main(){ ll n; std::cin >> n; if(n<=2){ return 2; } unordered_map kb; ll k = 2; while(k<65){ ll sum = 0; queue q; for (int i = 0; i < k-1; i++) { q.push(0); } q.push(1); sum += 1; while(sum<1e18+10){ q.push(sum); ll t = q.front(); q.pop(); sum += sum-t; if(kb[sum]==0){ kb[sum] = k; } } k++; } if(kb[n]==0){ std::cout << -1 << std::endl; }else{ std::cout << kb[n] << std::endl; } }