A. Number System
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Hacker Kirill was nostalgically going through his school notebooks on computer science and noticed that the number system was not indicated in some addition problems. He was wondering: is it possible to unambiguously determine the number system that was used for addition only by using the recording of a problem?

Help Kirill — write a program that, with given terms and sum, will unambiguously restore the number system used for addition or inform that unambiguous restoration is not possible.

Proceed from the assumption that the addition is performed correctly.

Input

The first line contains the first term, the second – second term, and the third – sum. To denote numbers use digits from «$$$0$$$» to «$$$9$$$» and capital Latin letters from «$$$A$$$» to «$$$Z$$$».

Terms and sum can be of different lengths, but the length of any of these numbers does not exceed $$$256$$$ digits.

Output

If unambiguous restoration of the number system is not possible, output $$$0$$$; otherwise – output the whole positive base of the number system.

Examples
Input
A
6
10
Output
16
Input
1
2
3
Output
0
Input
1
Y
Z
Output
0