#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int phi(int n){
    int sum=n;
    for(int i=2;i*i<=n;i++){
        int k=0;
        while(n%i==0) {
            n /= i;
            k++;
        }  
        if(k) (sum /= i) *= i - 1;
    }
    if(n>1) (sum /= n) *= n - 1;
    return sum;
}
int main(){
    int n;
    while(cin>>n){
        int sum = phi(n);
        cout<<sum<<endl;
    }
    return 0;
}