A - Relatives
#include<iostream> #include<cmath> using namespace std; #define ll long long ll euler(ll x) { ll i,res=x; for(i=2; i<sqrt(x)+1; i++) if(x%i==0) { res=res/i*(i-1); while(x%i==0) x/=i; } if(x>1) res=res/x*(x-1); return res; } int main() { ll n; while(cin>>n&&n) { cout<<euler(n)<<endl; } return 0; }