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 Python (judge verdict: Time Limit Exceeded)

#! usr/bin/env python
#_*_ coding:utf-8 _*_

import sys
import io

count = 1
n=int(input())
if n%2 != 0:
	for x in range(2,n):
	
		m=n
		gcd=x
		while m%gcd !=0 :
			r=m%gcd
			m   = gcd
			gcd = r
		if gcd == 1: count = count+1
else:
	
	for x in range(3,n,2):
	
		m=n
		gcd=x
		while m%gcd !=0 :
			r=m%gcd
			m   = gcd
			gcd = r
		if gcd == 1: count = count+1
print count