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 Ruby (judge verdict: Accepted)

n=gets.chomp.to_i
max_root=Math.sqrt(n).to_i
prime=Array.new
m=n
k=n
i=2
while i <= max_root
	if n%i==0
		prime << i
		n=n/i
	elsif i==2
		i+=1
	else
		i+=2
	end
end
if m==n || n!=1
	prime << n
end

prime.uniq!

j=0
while j <= prime.length-1
	k= k-k/prime[j]
	j+=1
end
puts k