A, B=map(int, input().split())
if A==B:
    print(A)
    exit()

if B - A<=1000:
    ans=A
    for i in range(A+1, B+1):
        ans=ans^i
    print(ans)
else:
    lis=[]
    for i in range(A, B+1):
        if i%4==0:
            break
        else:
            lis.append(i)
    for j in range(B, A-1, -1):
        if j%4==0:
            lis.append(j)
            break
        else:
            lis.append(j)
    for i in range(len(lis)):
        if i==0:
            ans=lis[i]
        else:
            ans=ans^lis[i]
    print(ans) A, B=map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B if A==B:
    print(A)
    exit() A==B A B print(A) print A exit() exit if B - A<=1000:
    ans=A
    for i in range(A+1, B+1):
        ans=ans^i
    print(ans)
else:
    lis=[]
    for i in range(A, B+1):
        if i%4==0:
            break
        else:
            lis.append(i)
    for j in range(B, A-1, -1):
        if j%4==0:
            lis.append(j)
            break
        else:
            lis.append(j)
    for i in range(len(lis)):
        if i==0:
            ans=lis[i]
        else:
            ans=ans^lis[i]
    print(ans) B - A<=1000 B - A B A 1000 ans=A ans A for i in range(A+1, B+1):
        ans=ans^i
     i range(A+1, B+1) range A+1 A 1 B+1 B 1 ans=ans^i ans ans^i ans i print(ans) print ans lis=[] lis [] for i in range(A, B+1):
        if i%4==0:
            break
        else:
            lis.append(i)
     i range(A, B+1) range A B+1 B 1 if i%4==0:
            break
        else:
            lis.append(i)
     i%4==0 i%4 i 4 0 break lis.append(i) lis.append lis append i for j in range(B, A-1, -1):
        if j%4==0:
            lis.append(j)
            break
        else:
            lis.append(j)
     j range(B, A-1, -1) range B A-1 A 1 -1 if j%4==0:
            lis.append(j)
            break
        else:
            lis.append(j)
     j%4==0 j%4 j 4 0 lis.append(j) lis.append lis append j break lis.append(j) lis.append lis append j for i in range(len(lis)):
        if i==0:
            ans=lis[i]
        else:
            ans=ans^lis[i]
     i range(len(lis)) range len(lis) len lis if i==0:
            ans=lis[i]
        else:
            ans=ans^lis[i]
     i==0 i 0 ans=lis[i] ans lis[i] lis i ans=ans^lis[i] ans ans^lis[i] ans lis[i] lis i print(ans) print ans B=map(int, input().split()) map(int, input().split()) B ans=ans^i ans^i ans lis=[] [] lis ans=ans^lis[i] ans^lis[i] ans ans=A A ans A, B=map(int, input().split()) map(int, input().split()) A ans=lis[i] lis[i] ans
A, B=map(int, input().split())
if A==B:
    print(A)
    exit()

if B - A<=1000:
    ans=A
    for i in range(A+1, B+1):
        ans=ans^i
    print(ans)
else:
    lis=[]
    for i in range(A, B+1):
        if i%4==0:
            break
        else:
            lis.append(i)
    for j in range(B, A-1, -1):
        if j%4==0:
            lis.append(j)
            break
        else:
            lis.append(j)
    for i in range(len(lis)):
        if i==0:
            ans=lis[i]
        else:
            ans=ans^lis[i]
    print(ans)
