All numbers between and are written in base-three numeral system, without leading zeros. Each number is given on a separate line. Then, the resulting lines are sorted lexicographically. Which number will be first?
The numbers and are given in decimal, and the answer should also be provided in decimal.
For example, if A = 2 and B = 12:
In this case, the answer will be (since in base three it is written as ).
Natural numbers and are given (1 \leq A \leq B \leq 10^{15}).
Output the answer.
Beispiel 1