#include using namespace std; using ll = long long; bool f(ll n, ll p){ bool flag = true; ll a = n%p; ll pow = p; while(n/pow>0){ ll b = (n/pow)%p; if(b!=a){ flag = false; break; } pow *= p; } return flag; } int main(){ ll n; cin >> n; ll ans = 0; for(int i = 2; i*i <= n; i++){ if(f(n, i)){ ans = i; break; } } ll num = floor(sqrt(n)); if(ans==0){ for(int i = num; i>=1; i--){ if(n%i==0) ans = n/i; } } cout << ans << endl; return 0; }