#include <iostream>
using namespace std;

int main() {
    long long n;
    cin >> n;

    long long ans = n;
    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            ans -= ans / i;
            while (n % i == 0) n /= i;
        }
    }
    if (n > 1) ans -= ans / n;

    cout << ans << endl;
    return 0;
}
