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: Wrong Answer)

import math

def plist(n):
	sqrt = int(math.sqrt(n))
	p = [1]*(sqrt+3)
	p[0] = 0
	for i in range(2,int(math.sqrt(sqrt))+2):
		if p[i]:
			p[2*i::i] = [0 for x in range(2*i,sqrt+3,i)]
	return p

def get_pfact(p,n):
	div = []
	sqrt = int(math.sqrt(n))
	for i in range(2,sqrt+3):
		if p[i] and n%i == 0:
			div.append(i)
	return div

def phai(n,div):
	ans = n
	for pf in div:
		ans *= (1-1/float(pf))
	return int(ans)

# main	
n = int(raw_input())
p = plist(n)
div = get_pfact(p,n)
print phai(n,div)