URI Online Judge | 2557


By Ricardo Oliveira, UFPR BR Brazil

Timelimit: 1

During his great adventure in Westeros, little Jon found a holy book that, according to the legends, was written by the old gods themselves. A particular sentence drawn the attention of the young adventurer:

The origin of the one who knows nothing will be revealed when the chosen one solves the riddle imposed by the gods. R+L=J.

The riddle really intrigued the boy. Little Jon then started to search for values of R, L and J that satisfy the equation cited in the book.

After some investigation, the young boy found two of the three cited values. Little Jon must now determine the third value, so the riddle can be solved and “the origin of the one who knows nothing” can be revealed.


The input contains several test cases. The only line of each test case contains a string in the form R+L=J. If the value of a variable is known, such value appears in the string instead the variable itself. Otherwise, the letter that indicate the variable appears normally.

It is guaranteed that exactly two of the three values are known. Also, all known values are between 1 and 106, inclusive. There is no leading zeros in the given values.

The input ends with end-of-file (EOF).


For each test case, print a single line containing the value of the unknown variable.

Input Sample Output Sample