#P1555. [USACO11NOV] 尴尬的数字 Awkward Digits B

[USACO11NOV] 尴尬的数字 Awkward Digits B

Description

Every time Bessie converts a number to a new base, she always writes exactly one digit incorrectly. For example, when she converts 14 to base 22, the correct result is 1110, but she might write 0110 or 1111. Bessie never accidentally inserts or deletes digits, so she might write an incorrect number that starts with 0.

Given Bessie's base 22 form of NN and base 33 form of NN after her conversion, compute the correct value of NN (in decimal). NN may be as large as 10910^9, and the input guarantees that the solution exists and is unique.

Input Format

The first line contains the base 22 representation of NN (with exactly one incorrect digit). The second line contains the base 33 representation of NN (with exactly one incorrect digit).

Output Format

Output a single line with the correct value of NN.

1010
212
14

Hint

Translated by ChatGPT 5