PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000245. Hàm phi Euler (Euler Totient Function)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Hàm phi Euler (Euler Totient Function)

Euler Totient Function

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Euler’s totient φ(n)\varphi(n) counts integers xx with 1≤x≤n1\le x\le n and gcd⁡(x,n)=1\gcd(x,n)=1. Determine φ(n)\varphi(n).

Input

Read one integer nn.

Output

Print one integer, φ(n)\varphi(n).

Subtasks

  • Subtask 1 (20 points): 1≤n≤1001\le n\le 100.
  • Subtask 2 (30 points): 1≤n≤100001\le n\le 10000.
  • Subtask 3 (50 points): 1≤n≤10000001\le n\le 1000000.

Examples

Example 1

Input

5

Output

4

Explanation

The integers coprime to 55 are 1, 2, 3, 4, giving 4 values.

Example 2

Input

1

Output

1

Explanation

The integers coprime to 11 are 1, giving 1 values.