Bomboslav likes to look out of the window in his room and watch lads outside playing famous shell game. The game is played by two persons: operator and player. Operator takes three similar opaque shells and places a ball beneath one of them. Then he shuffles the shells by swapping some pairs and the player has to guess the current position of the ball.

Bomboslav noticed that guys are not very inventive, so the operator always swaps the left shell with the middle one during odd moves (first, third, fifth, etc.) and always swaps the middle shell with the right one during even moves (second, fourth, etc.).

Let's number shells from 0 to 2 from left to right. Thus the left shell is assigned number 0, the middle shell is 1 and the right shell is 2. Bomboslav has missed the moment when the ball was placed beneath the shell, but he knows that exactly n movements were made by the operator and the ball was under shell x at the end. Now he wonders, what was the initial position of the ball?


-----Input-----

The first line of the input contains an integer n (1 ≤ n ≤ 2·10^9) — the number of movements made by the operator.

The second line contains a single integer x (0 ≤ x ≤ 2) — the index of the shell where the ball was found after n movements.


-----Output-----

Print one integer from 0 to 2 — the index of the shell where the ball was initially placed.


-----Examples-----
Input
4
2

Output
1

Input
1
1

Output
0



-----Note-----

In the first sample, the ball was initially placed beneath the middle shell and the operator completed four movements.  During the first move operator swapped the left shell and the middle shell. The ball is now under the left shell.  During the second move operator swapped the middle shell and the right one. The ball is still under the left shell.  During the third move operator swapped the left shell and the middle shell again. The ball is again in the middle.  Finally, the operators swapped the middle shell and the right shell. The ball is now beneath the right shell.

Difficulty: interview

Starter code:

Solutions:
def main():
	n = int(input())
	k = int(input())
	n %= 6
	a = [0, 1, 2]
	for i in range(1, n + 1):
		if (i % 2 == 1):
			a[0], a[1] = a[1], a[0]
		else:
			a[1], a[2] = a[2], a[1]
	print(a[k])


main()

import sys
n = int(input())
m = int(input())
z = [[0, 1, 2],
     [1, 0, 2],
     [1, 2, 0],
     [2, 1, 0],
     [2, 0, 1],
     [0, 2, 1]]
print(z[n % 6][m])


from sys import stdin, stdout

n = int(stdin.readline()) % 6
num = int(stdin.readline())

ans = [0, 1, 2]

while n > 1:
    ans = ans[1:] + [ans[0]]
    n -= 2

if n:
    ans[0], ans[1] = ans[1], ans[0]

stdout.write(str(ans[num]))

N = int(input())
N %= 6
x = int(input())
b = [0, 1, 2]
for i in range(N):
    if i % 2 == 0:
        b[0], b[1] = b[1], b[0]
    else:
        b[1], b[2] = b[2], b[1]
print(b[x])


A = [0, 1, 2]
B = [0] * 6
for i in range(6):
    B[i] = A[:]
    if i % 2 == 0:
        A[0], A[1] = A[1], A[0]
    else:
        A[1], A[2] = A[2], A[1]
n = int(input())
#n -= 1
n %= 6
x = int(input())
print(B[n][x])

n = int(input()) % 6
x = int(input())
p = [0, 1, 2]
for i in range(1, n + 1):
    if i % 2 == 1:
        p[0], p[1] = p[1], p[0]
    else:
        p[1], p[2] = p[2], p[1]
print(p[x])

import math, sys
def main():
	n = int(input())
	x = int(input())
	d0 = [0,1,2,2,1,0]
	d1 = [1,0,0,1,2,2]	
	d2 = [2,2,1,0,0,1]
	if (d0[n%6]==x):
		print(0)
	elif (d1[n%6]==x):
		print(1)
	else:
		print(2)
	
			
def __starting_point():
	main()

__starting_point()

n = int(input())
x = int(input())
n %= 6
a = [[0, 1, 2], [1, 0,2], [1, 2, 0], [2, 1, 0], [2, 0, 1], [0, 2, 1]]
c = a[n][x]
print(c)


n = int(input())
x = int(input())

res = [
    [0, 1, 2],
    [1, 0, 2],
    [1, 2, 0],
    [2, 1, 0],
    [2, 0, 1],
    [0, 2, 1],
]

pos = n % 6
print(res[pos][x])


a = [[1, 2, 3], [2, 1, 3], [2, 3, 1], [3, 2, 1], [3, 1, 2], [1, 3, 2]]

n = int(input())
x = int(input())

print(a[n % 6][x] - 1)

n = int(input())
x = int(input())
n %= 6
pos = 0
for i in range(1,n+1):
    if i%2 == 1:
        if pos == 1:
            pos = 0
        elif pos == 0:
            pos = 1
    else:
        if pos == 2:
            pos = 1
        elif pos == 1:
            pos = 2
if pos == x:
    print(0)
else:
    pos = 1
    for i in range(1,n+1):
        if i%2 == 1:
            if pos == 1:
                pos = 0
            elif pos == 0:
                pos = 1
        else:
            if pos == 2:
                pos = 1
            elif pos == 1:
                pos = 2
    if pos == x:
        print(1)
    else:
        print(2)
        


n=int(input())
a=["012","102","120","210","201","021"]
t=int(input())
print(a[n%len(a)][t])


# Author: Maharshi Gor

def read(type=int):
    return type(input())


def read_arr(type=int):
    return [type(token) for token in input().split()]


n = read()
x = read()
n %= 6

A = [
    [0, 1, 2],
    [1, 0, 2],
    [1, 2, 0],
    [2, 1, 0],
    [2, 0, 1],
    [0, 2, 1]
]
print(A[n][x])

n = int(input())
x = int(input())

n %= 6

odd = n % 2

for i in range(n):
    if odd:
        if x == 0:
            x = 1
        elif x == 1:
            x = 0
    else:
        if x == 1:
            x = 2
        elif x == 2:
            x = 1
    odd = not odd

print(x)


#! /usr/bin/python
# kmwho
# Codeforces 401 D2

def main():
    n = int(input())
    x = int(input())
    n = n % 6
    pos = [ 0,1,2 ]
    for i in range(1,n+1):
        if i%2 == 1:
            pos[0],pos[1] = pos[1], pos[0]
        else:
            pos[1],pos[2] = pos[2], pos[1]
    print(pos[x])


main()



n = int(input())
m = int(input())
n = n % 6
o = 0
for i in range(n):
    if i % 2 == 1:
        if o != 0:
            o = 3 - o
    else:
        if o != 2:
            o = 1 - o
if o == m:
    print(0)
else:
    o = 1
    for i in range(n):
        if i % 2 == 1:
            if o != 0:
                o = 3 - o
        else:
            if o != 2:
                o = 1 - o
    if o == m:
        print(1)
    else:
        print(2)



n = int(input())
x = int(input())
n %= 6
t = n
a = [0] * 3

a[x] = 1
for i in range(6 - n):
	if (i + t) % 2 == 0:
		a[0], a[1] = a[1], a[0]
	else:
		a[1], a[2] = a[2], a[1]
print(a.index(1))

def simulate(init, n):
    a = [0, 0, 0]
    a[init] = 1
    n %= 6
    for i in range(1, n + 1):
        if i % 2 == 1:
            a[0], a[1] = a[1], a[0]
        else:
            a[1], a[2] = a[2], a[1]
    for i in range(3):
        if a[i] == 1:
            return i

n = int(input())
x = int(input())
for i in range(3):
    if simulate(i, n) == x:
        print(i)
        break

n=int(input())
x=int(input())
lst=['012','102','120','210','201','021']
n %= 6
str = lst[n]
print(str[x])


n, x = int(input()), int(input())
n %= 6
ans = [[0, 1, 2], [1, 0, 2], [1, 2, 0], [2, 1, 0], [2, 0, 1], [0, 2, 1]]
print(ans[n][x])

n = int(input())
k = int(input())
n %= 6
d = [[0, 1, 1, 2, 2, 0], [1, 0, 2, 1, 0, 2], [2, 2, 0, 0, 1, 1]]
print(d[k][n])


a = ['012', '102', '120', '210', '201', '021']
n = int(input())
x = int(input())
print(a[n % 6][x])


positions = [[0, 1, 2], [1, 0, 2], [1, 2, 0], [2, 1, 0], [2, 0, 1], [0, 2, 1]]
n = int(input())
x = int(input())
k = n % 6
print(positions[k][x])

n=int(input())
m=int(input())
n=n%6
arr=[0,0,0]
arr[m]=1
#print(arr)
for i in range(6-n):
    j=6-n+i
    if j%2==0:
        arr[0],arr[1]=arr[1],arr[0]
    else:
        arr[1],arr[2]=arr[2],arr[1]
    #print(arr)
print(arr.index(1))


n = int(input())
x = int(input())

n %= 6
a, b, c = (x == 0), (x == 1), (x == 2)

for i in reversed(list(range(n))):
    if i % 2 == 0:
        a, b = b, a
    else:
        b, c = c, b

if a:
    print(0)
elif b:
    print(1)
else:
    print(2)