eolymp
bolt
Try our new interface for solving problems
Problems

The equality

The equality

Returning home from school, Peter each time paying attention to the inscription on the fence "\textbf{1} + \textbf{1} = \textbf{10}" and marveled obvious he was wrong. But once he realized that this equality is true if we consider it in the binary system. He was so struck by this idea that he decided to definitely come up with their three numbers so that the sum of the first two was equal third in a system of notation. Now, he enumerates three numbers, which, in his view, deserve to be on the fence. Peter chooses the number of \textbf{A}, \textbf{B}, \textbf{C}, written to decimal digits, and further attempts to find the radix \textbf{K}, in which the equality of \textbf{A} + \textbf{B} = \textbf{C} proved to be correct. Peter considers the system with base from \textbf{2} to infinity. Since each triple check - a time-consuming exercise, to help Pete should write a program that facilitates the calculations. Now, he enumerates three numbers, which, in his view, deserve to be on the fence. Peter chooses the number of A, B, C, written to decimal digits, and further attempts to find the radix K, in which the equality of A + B = C proved to be correct. Peter considers the system with base from 2 to infinity. \InputFile The first line contains the number of \textbf{A}, consisting of numbers from \textbf{0} to \textbf{9} lengths not more than \textbf{200}. In the following two lines in the same format recorded in the number of \textbf{B} and \textbf{C}. All numbers are nonnegative and without leading zeros. \OutputFile Derive the minimum radix, in which the equality \textbf{A} + \textbf{B} = \textbf{C}. If that does not exist, then bring up to \textbf{0}. Derive the minimum radix, in which the equality A + B = C. If that does not exist, then bring up to 0.
Time limit 1 second
Memory limit 64 MiB
Input example #1
9
8
17
Output example #1
10
Source Svenskt Mästerskap i Programmering/Norgesmesterskapet 2004