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