Irreducible Polynomials Junior#4562

Irreducible Polynomials Junior

1 second
256 megabytes
Easy

Given a prime number , consider the set Z_p = \{0, 1, \ldots, p-1\}—the field of remainders modulo . In this field, both multiplication and addition are performed modulo .

Now, consider the set of monic polynomials over this field of the form

f(x) = x^n + a_{n-1} x^{n-1} + \ldots + a_1 x + a_0

where is the degree of the polynomial, is the variable, and a_i \in Z_p are coefficients.

For example, the polynomial x^2 + x + 1 in the field Z_2 is irreducible. A monic polynomial is called irreducible if it cannot be represented as f(x) = p(x) \cdot q(x), where and are polynomials of lower degree than . Notably, this is the only irreducible polynomial of degree two in Z_2.

Your task is to compute the number of irreducible monic polynomials of degree in the field Z_p.

Input

The input consists of a single line containing two integers and (1 \leq p, n \leq 10^9, 1 \leq p^n < 10^{18}).

Output

Output the number of irreducible monic polynomials of degree in the field Z_p.

Examples

Example 1

Loading
Loading