#include <iostream>
#include <conio.h>
using namespace std;
void phi(){
int n,result;
cin >> n;
result = n;
for (int i = 2; i*i <= n; ++i){
if (n % i == 0){
while (n % i == 0){
n /= i;
}
result -= result / i;
}
}
if (n > 1){
result -= result / n;
}
cout << result;
}
int main(){
phi();
_getch();
return 0;
}