The favorite game of Mr.Cocktail is dota2. Serpentine walking is a useful skill to dodge the enemy's attack. Serpentine walking refers to the path of movement that keeps swing direction like a snake. Suppose the map is a

two-dimensional plane. Mr.Cocktail at the point
%7D)
in initial.
He will first go to the right to the end, that is, point
%7D)
. Then turn and go one step upwards to point
%7D)
. Go to the left again to the end, that is, point
%7D)
,. Then go one step up, and go to the right again to the end.
The picture above is the action line when

and

.
Now the map size is

. The number of steps

of Cocktail's movement are known. Find the Manhattan distance from the position after

steps to the starting point according to the rule.
Manhattan distance Definition: The distance between two points measured along axes at right angles. In a plane with

at
%7D)
and

at
%7D)
, it is

.