#include using namespace std; int main(){ long long N; cin >> N; bool ok = false; for (long long i = 2; i <= N; i++){ long long N2 = N; vector A; while (N2 > 0){ A.push_back(N2 % i); N2 /= i; } bool same = true; int cnt = A.size(); for (int j = 1; j < cnt; j++){ if (A[j] != A[0]){ same = false; } } if (same){ cout << i << endl; ok = true; break; } if (A.size() <= 2){ break; } } if (!ok){ for (int i = (int) sqrt(N); i >= 1; i--){ if (N % i == 0){ long long b = N / i - 1; if (b > i && N / b == N % b){ cout << b << endl; break; } } } } }