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

#GL0000246. Phân số cơ bản không thể rút gọn (Irreducible Basic Fractions)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Phân số cơ bản không thể rút gọn (Irreducible Basic Fractions)

Irreducible Basic Fractions

Source: UVa

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≤1000001\le n\le 100000.
  • Subtask 3 (50 points): 1≤n≤9999999991\le n\le 999999999.

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.