#include<iostream>
#include<vector>
using namespace std;
int main(int argc, char const *argv[]) {
    int N,origN;cin >> N; origN = N;
    vector<int> div;
    for(int d=2;d*d<=N;d++){
        if(N%d == 0){
            div.push_back(d);
            while(N % d == 0)N /= d;
        }
    }
    if(N != 1) div.push_back(N);
    int M = div.size(), ans=0;
    for(int bit=1;bit<(1<<M);bit++){
        int popcnt = __builtin_popcount(bit);
        int mul = 1;
        for(int i=0; i<M; i++){
            if(bit >> i&1)mul *= div[i];
        }
        if(popcnt % 2 == 1) ans += origN/mul;
        else                ans -= origN/mul;
    }
    ans = origN - ans;
    cout << ans << endl;
    return 0;
}

