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.to_i

def totient(n)
	t = n
	i = 2
	while i * i <= n
		if n % i == 0
			t = t / i * (i - 1)
			n /= i while n % i == 0
		end
		i += 1
	end
	t = t / n * (n - 1) if n != 1
	t
end

p totient n