N,X=map(int,input().split()) M=10**5 if X>=2: if N%4==0: ans_lst=[X,1,2,3] elif N%4==1: ans_lst=[X] elif N%4==2: ans_lst=[X^1,1] else: ans_lst=[X^1,2,3] else: if N%4==0: ans_lst=[1,2,4,6] elif N%4==1: ans_lst=[1] elif N%4==2: ans_lst=[2,3] else: ans_lst=[3,4,6] for m in range(8,M+2,4): if len(ans_lst)