#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define RFOR(i,s,e) for(int (i) = (s);(i) >= (e);(i)--)
#define rep(i,n) FOR(i,0,n-1)
#define MOD 1000000007
 
signed main(){
	int n;cin>>n;
	int originN = n;
	vector<int> soin;
	for(int i=2;i*i<=n;i++)
	{
		if(n%i==0)soin.push_back(i);
		while(n%i==0)n/=i;
	}
	if(n>1) soin.push_back(n);
	int kosuu = soin.size();
	int ans = 0;
	for(int i=1;i<(1<<kosuu);i++)
	{
		int popcnt = __builtin_popcount(i);
		int mul = 1;
		for(int j=0;j<kosuu;j++) if((i>>j)&1)mul*=soin[j];
		if(popcnt%2 == 1) ans += originN/mul;
		else ans -= originN/mul;
	}
	
	cout << originN - ans << endl;
	
}
