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

n = int(input())
def decomp(a):
    sqrt = round(n ** 0.5 + 0.5)
    factors = []
    for i in range(2, sqrt + 1):
        if not a % i:
            factors.append(i)
            while a % i == 0:
                a //= i
    if a != 1:
        factors.append(a)
    return factors
phi = n
for i in decomp(n):
    phi *= ((i - 1) / i)
print(int(phi))