The aliens
During Science Experiment Nakodilly accidentally received a message of aliens, which contains a formula of the form
A + B = C.
The public began to wonder what the same notation used by aliens. Since the extraterrestrial civilization was developed enough to send an interstellar message Nakodilla suggested that the radix quite a bit. Required to write a program that finds the minimum radix at which this equality holds.
Input
In a single line of input data is the equation of the form A+B=C. The string does not contain spaces, and the numbers are composed of capital letters and numbers and do not contain more than 5 characters.
Output
You want to display a single number - the desired radix. If such a number system does not exist, then output -1. It is guaranteed that the answer does not exceed 36.