#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int n;
    cin >> n;
    vector<int>div;
    int init_n = n;
    for(int i = 2;i*i<=n;i++) {
        if(n%i==0)div.push_back(i);
        while(n%i==0) {
            n /= i;
        }
    }
    if(n != 1) div.push_back(n);
    int ans = 0;
    int m = div.size();
    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 == 0) ans -= init_n/mul;
        else ans += init_n/mul;
    }
    ans = init_n - ans;
    cout << ans << endl;

}
