#include using namespace std; using ll = long long; template using vec = vector; template using vvec = vector>; template bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;} template bool chmax(T& a,T b){if(a2) ans = N-1; for(ll i=2;i*i<=N;i++){ ll a = i; while(true){ a *= i; ll now = (a-1)/(i-1); if(now>N) break; if(N%now==0 && N/now