#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;

i64 get_min_p(i64 n) {
    for (i64 i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return i;
        }
    }
    return n;
}

int main() {
    i64 n;
    cin >> n;
    i64 k = n;
    while (n > 1) {
        int p = get_min_p(n);
        k = k / p * (p - 1);
        while (n % p == 0) {
            n /= p;
        }
    }
    cout << k << endl;
}
