//ignore header files#define max 100000boolis_prime[max+1];unsignedlonglongprime[50000+1];intmain(intargc,charconst*argv[]){intm=0;for(unsignedlonglongi=2;i<=max;i++){if(!is_prime[i]){prime[m++]=i;for(unsignedlonglongj=i*i;j<=max;j=j+i){is_prime[j]=true;}}}//printf("%llu\n",prime[0]);unsignedlonglongn;while(~scanf("%llu",&n)&&n){if(n==1){printf("0\n");continue;}vector<int>factor;inttmp=n;for(inti=0;i<m&&prime[i]*prime[i]<=n;i++){if(n%prime[i]==0){factor.push_back(prime[i]);do{n=n/prime[i];}while(n%prime[i]==0);}}if(n>1){factor.push_back(n);}intl=factor.size();intans=tmp;for(inti=0;i<l;i++){//printf("%lf\n",1-1.0/factor[i]);ans=ans/factor[i]*(factor[i]-1);}printf("%d\n",(ans));}return0;}