Powers of Three Walk

Given a target point, decide whether it is reachable if stage k moves exactly 3^k in one of the four axis directions.

Medium5MathNumber theoryBit manipulationInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

Donghyeok stands at the origin (0,0)(0, 0) of a plane of infinite size.

He moves in numbered stages and wants to arrive at the point (x,y)(x, y). Stage numbers start at 00 and grow by 11.

At stage kk he picks one of four directions, right (xx increases), left (xx decreases), up (yy increases), or down (yy decreases), and then moves exactly 3k3^k in that direction. He cannot skip a stage.

He performs as many stages as he wants and then stops. Stopping at the origin without performing a single stage is allowed.

Given xx and yy, write a program that decides whether (x,y)(x, y) can be reached from (0,0)(0, 0).

Input

The first line contains two integers xx and yy separated by a space. (109x,y109-10^9 \le x, y \le 10^9)

Output

Print 11 if (x,y)(x, y) can be reached from (0,0)(0, 0), and 00 otherwise.

If xx and yy are both 00, he is already there before any stage, so print 11.