#include typedef long long ll; using namespace std; ll n, f[200010]; bool check(ll k) { for (int i=1; i=i-k; j--) f[i] += f[j]; if (f[i] == n) return true; else if (f[i] > n) return false; } return false; } int main() { cin >> n; for (int i=1; i<=n; i++) if (check(i)) { cout << i; return 0; } cout << -1; }