Problem:
Euler's Phi Function

For given integer n, count the totatives of n, that is, the positive integers less than or equal to n that are relatively prime to n.

Input

n

An integer n (1 ≤ n ≤ 1000000000).

Output

The number of totatives in a line.

Sample Input 1

6

Sample Output 1

2

Sample Input 2

1000000

Sample Output 2

400000

Solution in C (judge verdict: Accepted)

#include <stdio.h>

int main(){
  long int n, now, i;

  scanf("%ld",&n);
  now = n;

  for(i=2; i<=n && now!=1; i++){
    if(now%i==0){
      n = n*(i-1)/i;
      while(now%i==0)
	now/=i;
    }
  }
  printf("%ld\n",n);
  return 0;
}