n=input() p=n%2*n or n/2 i=2 q=1 while i*i<=p: c=1 while p%i<1:c+=1;p/=i q*=(i**c-1)/~-i;i+=1 print(p+(p>1))*q