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

require 'prime'
def phi_func(n)
    if n.prime?
        return n-1
    else
        cnt=0
        for i in 1..n
            if n.gcd(i)==1
                cnt+=1
            end
        end
        return cnt
    end
end

n=gets.to_i
fct=n.prime_division.map{|fac| fac[0]*fac[1]}
ans=1
fct.each do |elem|
    ans*=phi_func(elem)
end
p ans