Innovative hanger
The innovative hanger consists of levels of interconnected rods. Level (with ) consists of horizontal rods.
The middle of the rod at is attached to the wall. At all other levels, the middle of the -th (for ) rod is attached to the left side of the -th rod (rounded up when dividing by ) of the previous level for odd , or to the right side of the same rod if is even. There are coat hooks at both ends of each rod on the last level. The hooks are numbered from left to right with numbers from to . For example, the hanger for = looks like this:
Masha wants to hang all her jackets on her new hanger. The weight of each jacket is equal to one. To avoid breaking the fragile structure, she must hang the jackets in such an order that the difference between the total weight at the left end of any rod and the total weight at the right end of the same rod after adding another jacket is either or . (According to the laws of physics, the difference can be equal to , but Masha considers the skew to the right to be terrible.) The rods are so thin that their weight can be neglected. Masha has heard a lot about your professionalism and asks for your help. Write a program that, given and , finds the number of the hook modulo on which Masha must hang her jacket at the -th step.
Input
The only line contains two integers and .
Output
Print one integer — the number of the hook on which Masha should hang her jacket at the -th step modulo .
Limitations
Examples
Note
In the first example, the hooks should be used in the following order: , , , , , , , . In the second step, Masha must hang her jacket on hook number .
In the second example, the order of hooks is: , , , , , , , , , , etc.