If a number where the first digit is not zero reads the same from left to right as from right to left, we call it a palindrome number.
For example, given the decimal number , the sum of (i.e. read from right to left) is which is a palindrome number.
Another example for decimal number :
STEP 1:
STEP 2:
STEP 3:
STEP 4:
A step here refers to one addition done in base . The above example used steps to get a palindrome number, .
Given the base and the initial number (less than or equal to digits) in base , find the minimum steps to get a palindrome number. If it is impossible to get a palindrome number in less than or exactly steps, output Impossible!
.
Input Specification
The first line will contain .
The second line will contain .
Output Specification
If you can get a palindrome number within steps, output the number of steps in the form of STEP=ans
, where ans
is the minimum number of steps to get a palindrome number. Otherwise, output Impossible!
.
Sample Input
10
87
Sample Output
STEP=4
Problem translated to English by .
Comments