Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/sonlar-eyler-funksiyasi

Euler's totient function

Medium 1000 ms 128 MB 64%
Share

You are given a positive integer $n$. Find how many of the numbers from $1$ to $n$ are coprime with $n$, that is, the numbers $k$ with $\gcd(k, n) = 1$. This number is denoted $\varphi(n)$; $\varphi(1) = 1$.

The numbers from one to n in a row, those coprime with n highlighted

Input

One positive integer $n$.

Output

One integer — $\varphi(n)$.

Note

$1 \le n \le 10^{12}$

Examples

Input #1
12
Output #1
4
Input #2
9
Output #2
6

Sign in to submit a solution

Signing up is free and takes a minute.