#define others
#ifdef poj
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#endif // poj
#ifdef others
#include <bits/stdc++.h>
#endif // others
//#define file
#define all(x) x.begin(), x.end()
using namespace std;
const double eps = 1e-8;
int dcmp(double x) { if(fabs(x)<=eps) return 0; return (x>0)?1:-1;};
typedef long long LL;
namespace solver {
const int maxn = 300;
int phi(int x) {
int v = x;
for(int i = 2; i <= sqrt(x); i++){
if(x % i == 0) {
v *= i - 1;
v /= i;
while(x % i == 0) {
x /= i;
}
}
}
if(x != 1) {
v *= x-1;
v /= x;
}
return v;
}
void solve() {
int n;
scanf("%d", &n);
cout<<phi(n);
}
}
int main() {
#ifdef file
freopen("gangsters.in", "r", stdin);
freopen("gangsters.out", "w", stdout);
#endif // file
// int t;
// scanf("%lld", &t);
// while(t--)
solver::solve();
return 0;
}
/*
4
0 1
1 2
2 3
3 4
*/