Limits 1s, 512 MB

You may have played the game The Tower of Hanoi. The game contains three towers. You've to place 8 discs from left tower to right tower while adhering to certain rules. If you want to move n discs from the left tower to right one then you need to make a minimum of 2n-1 moves.

Forget that. Now we will play the game Tower of Sticks.

This is much more easier than the game Tower of Hanoi. In this game there will be two stacks of sticks A and B. You have to take some sticks from stack A and place them on stack B (or the reverse: take from B to and place on A) so that both stacks have the same number of sticks.

Input

You'll be given two unsigned integers each line as input. These two numbers indicate the number of discs in tower A and B respectively. The numbers will be separated with spaces. Your program should stop when both numbers are inputted equal.

Output

Print how many discs should be moved from one tower to another so that, both towers have equal number of discs. If it is not possible then print "impossible".

Sample

InputOutput
10 6
4 6
7 6
22 10
36 36
2
1
impossible
6

Submit

Login to submit.

Statistics

92% Solution Ratio
edge555Earliest, Dec '19
edge555Fastest, 0.0s
Dipra_IrhamLightest, 0 B
bokaifShortest, 105B
Toph uses cookies. By continuing you agree to our Cookie Policy.