模板题
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <list>
#include <map>
#define INF 0x3f3f3f3f
#define P(x) x>0 ? x : 0
#define MID l + r >> 1
#define lsn rt << 1
#define rsn rt << 1 | 1
#define Lson lsn, l, mid
#define Rson rsn, mid+1, r
#define QL Lson, ql, qr
#define QR Rson, ql, qr
#define lowbit(x) x & (-x)
using namespace std;
typedef long long ll;
typedef vector<int>:: iterator VITer;
const ll maxN=1e7;
bool Is_Prime(ll x)
{
if( x == 2 ) return true;
for(ll i = 2 ; i * i <= x ; i++)
{
if( x % i == 0)
return false;
}
return true;
}
set<ll> st;
void prime_factor(ll x)
{
for(ll i = 2 ; i <= x ; i++)
{
if(Is_Prime(x))
{
st.insert(x) ;
return ;
}
if(Is_Prime(i))
{
while(x % i == 0)
{
x /= i;
st.insert(i);
}
}
}
}
ll Euler(ll x)
{
if(x == 1) return 1;
ll up = x, down = 1;
prime_factor(x);
while(! st.empty())
{
int tmp = *st.begin();
st.erase(st.begin());
up *= (tmp - 1);
down *= tmp;
}
return up / down;
}
int main()
{
ll n;
while(~ scanf("%lld", &n) && n)
{
printf("%lld\n", Euler(n));
}
return 0;
}