#include <iostream>
#include <cmath>
#include <cstring>
#include <windows.h>
using namespace std;
bool isPrime[100000];
void primeRadiation( const int& size ){
memset( isPrime, true, sizeof( isPrime ) );
isPrime[1] = false;
for( int i = 4; i <= size; i += 2 )
isPrime[i] = false;
for( int i = 3; i <= sqrt( size ); ++i ){
if( isPrime[i] ){
const int step = 2 * i;
for( int j = i * i; j <= size; j += step )
isPrime[j] = false;
}
}
}
int main(){
int num;
while( cin >> num ){
if( num == 0 )
break;
double res = num;
int temp = num;
primeRadiation( num );
for( int i = 2; i <= num; ++i ){
if( isPrime[i] && temp % i == 0 ){
res *= ( 1 - 1.0 / i );
while( temp % i == 0 )
temp /= i;
}
}
cout << res << endl;
}
return 0;
}