407380: GYM102780 D Power play

Memory Limit:64 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Power playtime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output

While analyzing a mathematical problem, a programmer, Basil by name, noticed an interesting fact: for the numbers 2 and 4 holds the equality $$$2^4 = 4^2$$$. 'This could be a great challenge for the participants of the programming championship,' he thought. Unfortunately, Basil could not find other such pairs of numbers, the pair 2 and 4 was his only combination that he could think of. 'Okay, then we'll change the conditions, let there be three numbers,' Basil decided. The written program of enumeration options confirmed that with three numbers the task made sense.

Your task: find the integer $$$x$$$ by the given integers $$$a$$$ and $$$b$$$ such that falls in the range from 1 to $$$10^{18}$$$ (Basil's program didn't deal with greater numbers) such that $$$a^x = x^b$$$. If there are several such numbers, type the smaller of them. If such a number does not exist, type 0.

Input

The input data consist of two integers $$$a$$$ and $$$b$$$ ($$$2 \leq a, b \leq 10000$$$; $$$a \neq b$$$), separated by a blank space.

Output

The integer $$$x$$$ if there is a solution, or 0 (zero) if there is no solution.

ExamplesInput
2 4
Output
16
Input
2 6
Output
0
Input
2 32
Output
256
Input
100 20
Output
10

加入题单

算法标签: