Strange Limit#5665

Strange Limit

1 second
64 megabytes
Very easy

Consider the sequence a_n defined by the following recurrence:

a_1 = p,\\ a_{n+1} = p^{a_n}\quad \text{for } n \ge 1,

where is a prime number.

Let

b_n = a_n \bmod m!,

where denotes the factorial of , that is, m! = 1 \times 2 \times \dots \times m.

It may seem strange, but for all and all , the sequence b_n has a limit as n \to +\infty. Your task is to find this limit. Given and , find this value:

\lim_{n \to +\infty} (a_n \bmod m!).

Input

The input contains two integers and (2 \le p, m \le 12, and is prime).

Output

Output the limit described above.

Examples

Example 1

Loading
Loading