### BUGGY CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/9
Solved on 2019/3/9
@author: shinjisu
"""


# ABC 121
# import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**12


def dmp(x, cmt=''):
    global debug
    if debug:
        if cmt != '':
            print(cmt, ':  ', end='')
        print(x)
    return x


def prob_D_v1():
    A, B = getIntList()
    dmp((A, B))
    res = A
    for i in range(A+1, B+1):
        res = res ^ i
    dmp(res)
    return res


def prob_D_v2():
    A, B = getIntList()
    dmp((A, B))
    if (B-A) % 2 == 0:
        res = (A^B) ^ (A+B)//2
        count = (B-A)//2 
    else:
        res = (A^B)
        count = (B-A)//2
    dmp((res,count))
    if count % 2 == 0:
        res = res ^ res
    dmp(res)
    return res


def prob_D_v3():
    A, B = getIntList()
    dmp((A, B))
    pairCount = (B-A+1)//2
    dmp(pairCount, 'pairCount')
    xorAB = A ^ B
    dmp(xorAB, 'xorAB')
    res = xorAB
    if pairCount % 2 == 0:
        res = res ^ xorAB  # 0
    dmp(res)
    if (B-A+1) % 2 == 1:
        res = res ^ (A+B)//2
    dmp(res)
    return res


def answer(a, b):
    ans = 0
    for i in range(a, b+1):
        ans = ans ^ i
    dmp(ans, 'ans')
    return ans


def prob_D():
    A, B = getIntList()
    dmp((A, B))
    count = B-A+1
    mod4 = count % 4
    dmp((count, mod4), 'count, mod4')
    if mod4 == 0:
        if A % 2 == 0:
            res = 0
        else:
            res = A ^ 1 ^ B
    elif mod4 == 1:
        if A % 2 == 0:
            res = B
        else:
            res = A
    elif mod4 == 2:
        if A % 2 == 0:
            res = 1
        else:
            res = A ^ B
    else:  # == 3
        if A % 2 == 0:
            res = 1 ^ B
        else:
            res = A ^ 1
    dmp(res)
    answer(A, B)
    return res


debug = False  # True False
ans = prob_D()
print(ans)
#for row in ans:
#    print(row)




### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/9
Solved on 2019/3/9
@author: shinjisu
"""


# ABC 121
# import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**12


def dmp(x, cmt=''):
    global debug
    if debug:
        if cmt != '':
            print(cmt, ':  ', end='')
        print(x)
    return x


def prob_D_v1():
    A, B = getIntList()
    dmp((A, B))
    res = A
    for i in range(A+1, B+1):
        res = res ^ i
    dmp(res)
    return res


def prob_D_v2():
    A, B = getIntList()
    dmp((A, B))
    if (B-A) % 2 == 0:
        res = (A^B) ^ (A+B)//2
        count = (B-A)//2 
    else:
        res = (A^B)
        count = (B-A)//2
    dmp((res,count))
    if count % 2 == 0:
        res = res ^ res
    dmp(res)
    return res


def prob_D_v3():
    A, B = getIntList()
    dmp((A, B))
    pairCount = (B-A+1)//2
    dmp(pairCount, 'pairCount')
    xorAB = A ^ B
    dmp(xorAB, 'xorAB')
    res = xorAB
    if pairCount % 2 == 0:
        res = res ^ xorAB  # 0
    dmp(res)
    if (B-A+1) % 2 == 1:
        res = res ^ (A+B)//2
    dmp(res)
    return res


def answer(a, b):
    ans = 0
    if debug:
        for i in range(a, b+1):
            ans = ans ^ i
        dmp(ans, 'ans')
    return ans


def prob_D():
    A, B = getIntList()
    dmp((A, B))
    count = B-A+1
    mod4 = count % 4
    dmp((count, mod4), 'count, mod4')
    if mod4 == 0:
        if A % 2 == 0:
            res = 0
        else:
            res = A ^ 1 ^ B
    elif mod4 == 1:
        if A % 2 == 0:
            res = B
        else:
            res = A
    elif mod4 == 2:
        if A % 2 == 0:
            res = 1
        else:
            res = A ^ B
    else:  # == 3
        if A % 2 == 0:
            res = 1 ^ B
        else:
            res = A ^ 1
    dmp(res)
    #answer(A, B)
    return res


debug = False  # True False
ans = prob_D()
print(ans)
#for row in ans:
#    print(row)