407380: GYM102780 D Power play
Description
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.
InputThe input data consist of two integers $$$a$$$ and $$$b$$$ ($$$2 \leq a, b \leq 10000$$$; $$$a \neq b$$$), separated by a blank space.
OutputThe integer $$$x$$$ if there is a solution, or 0 (zero) if there is no solution.
ExamplesInput2 4Output
16Input
2 6Output
0Input
2 32Output
256Input
100 20Output
10