long n;main(i){for(i+=scanf("%ld",&n);i<1e6&&n%++i;);n=!printf("%ld",n%i?n>>~n%2:i);}