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

#GL0000250. Các số nguyên tố cùng nhau (Relatives)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Các số nguyên tố cùng nhau (Relatives)

Relatives

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Given a positive integer nn, count positive integers xx with 1≤x<n1\le x<n and gcd⁡(x,n)=1\gcd(x,n)=1.

Input

Read one integer nn.

Output

Print the count of integers x<nx<n coprime to nn; print 0 for n=1n=1.

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≤10000000001\le n\le 1000000000.

Examples

Example 1

Input

7

Output

6

Explanation

There are 6 coprime integers below 77: 1, 2, 3, 4, 5, 6.

Example 2

Input

12

Output

4

Explanation

There are 4 coprime integers below 1212: 1, 5, 7, 11.

Example 3

Input

1

Output

0

Explanation

There are 0 coprime integers below 11: .