Calculation of the multiplicative Euler's totient function for large numbers

Rust Hard math

Task «Calculation of the multiplicative Euler's totient function for large numbers»

Given a natural number n (1 ≤ n ≤ 10^12). It is necessary to compute the value of Euler's totient function φ(n) — the number of integers from 1 to n that are coprime to n. Use prime factorization by trial division up to sqrt(n) and the Sieve of Eratosthenes algorithm for precomputing prime numbers up to 10^6. Output the result.

Input Format

One integer n.

Output Format

One integer — the value of φ(n).

Examples

Example 1

INPUT
1
OUTPUT
1

Example 2

INPUT
2024-12-31
OUTPUT
Вторник

Example 3

INPUT
10
OUTPUT
4

Example 4

INPUT
2000-01-01
OUTPUT
Суббота
main.rs