import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)]

a,b = MI()

if a % 2 == 0:
    if b % 2 == 0:
        if (b-a) % 4 == 2:
            print(b + 1)
        else:
            print(b)
    else:
        if (b-a) % 4 == 1:
            print(1)
        else:
            print(0)
else:
    if b % 2 == 0:
        if (b-a) % 4 == 1:
            bst = bin(b)
            ast = bin(a)
            anst = '0b'
            if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):

                    anst += bst[2+i]
            for i in range(len(ast) -2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:],2)
            print(aa)

        else:
            bst = bin(b)
            ast = bin(a)
            anst = '0b'
            if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):
                    anst += bst[2 + i]
            for i in range(len(ast) - 2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:], 2)
            print(aa - 1)
    else:
        if (b-a) % 4 == 2:
            print(a-1)
        else:
            print(a) import bisect,collections,copy,heapq,itertools,math,numpy,string bisect collections copy heapq itertools math numpy string import sys sys def S(): return sys.stdin.readline().rstrip() S def I(): return int(sys.stdin.readline().rstrip()) I def MI(): return map(int,sys.stdin.readline().rstrip().split()) MI def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) LI def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)] LS a,b = MI() a MI() MI b if a % 2 == 0:
    if b % 2 == 0:
        if (b-a) % 4 == 2:
            print(b + 1)
        else:
            print(b)
    else:
        if (b-a) % 4 == 1:
            print(1)
        else:
            print(0)
else:
    if b % 2 == 0:
        if (b-a) % 4 == 1:
            bst = bin(b)
            ast = bin(a)
            anst = '0b'
            if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):

                    anst += bst[2+i]
            for i in range(len(ast) -2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:],2)
            print(aa)

        else:
            bst = bin(b)
            ast = bin(a)
            anst = '0b'
            if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):
                    anst += bst[2 + i]
            for i in range(len(ast) - 2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:], 2)
            print(aa - 1)
    else:
        if (b-a) % 4 == 2:
            print(a-1)
        else:
            print(a) a % 2 == 0 a % 2 a 2 0 if b % 2 == 0:
        if (b-a) % 4 == 2:
            print(b + 1)
        else:
            print(b)
    else:
        if (b-a) % 4 == 1:
            print(1)
        else:
            print(0) b % 2 == 0 b % 2 b 2 0 if (b-a) % 4 == 2:
            print(b + 1)
        else:
            print(b)
     (b-a) % 4 == 2 (b-a) % 4 b-a b a 4 2 print(b + 1) print b + 1 b 1 print(b) print b if (b-a) % 4 == 1:
            print(1)
        else:
            print(0) (b-a) % 4 == 1 (b-a) % 4 b-a b a 4 1 print(1) print 1 print(0) print 0 if b % 2 == 0:
        if (b-a) % 4 == 1:
            bst = bin(b)
            ast = bin(a)
            anst = '0b'
            if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):

                    anst += bst[2+i]
            for i in range(len(ast) -2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:],2)
            print(aa)

        else:
            bst = bin(b)
            ast = bin(a)
            anst = '0b'
            if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):
                    anst += bst[2 + i]
            for i in range(len(ast) - 2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:], 2)
            print(aa - 1)
    else:
        if (b-a) % 4 == 2:
            print(a-1)
        else:
            print(a) b % 2 == 0 b % 2 b 2 0 if (b-a) % 4 == 1:
            bst = bin(b)
            ast = bin(a)
            anst = '0b'
            if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):

                    anst += bst[2+i]
            for i in range(len(ast) -2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:],2)
            print(aa)

        else:
            bst = bin(b)
            ast = bin(a)
            anst = '0b'
            if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):
                    anst += bst[2 + i]
            for i in range(len(ast) - 2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:], 2)
            print(aa - 1)
     (b-a) % 4 == 1 (b-a) % 4 b-a b a 4 1 bst = bin(b) bst bin(b) bin b ast = bin(a) ast bin(a) bin a anst = '0b' anst '0b' if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):

                    anst += bst[2+i]
             len(bst) - len(ast) > 0 len(bst) - len(ast) len(bst) len bst len(ast) len ast 0 for i in range(len(bst) - len(ast)):

                    anst += bst[2+i]
             i range(len(bst) - len(ast)) range len(bst) - len(ast) len(bst) len bst len(ast) len ast anst += bst[2+i] anst bst[2+i] bst 2+i 2 i for i in range(len(ast) -2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:],2)
             i range(len(ast) -2) range len(ast) -2 len(ast) len ast 2 if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                 ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i] ast[-len(ast) + 2 + i] ast -len(ast) + 2 + i -len(ast) + 2 -len(ast) len(ast) len ast 2 i bst[-len(ast) + 2 + i] bst -len(ast) + 2 + i -len(ast) + 2 -len(ast) len(ast) len ast 2 i anst += '0' anst '0' anst += '1' anst '1' aa = int(anst[2:],2) aa int(anst[2:],2) int anst[2:] anst 2: 2 2 print(aa) print aa bst = bin(b) bst bin(b) bin b ast = bin(a) ast bin(a) bin a anst = '0b' anst '0b' if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):
                    anst += bst[2 + i]
             len(bst) - len(ast) > 0 len(bst) - len(ast) len(bst) len bst len(ast) len ast 0 for i in range(len(bst) - len(ast)):
                    anst += bst[2 + i]
             i range(len(bst) - len(ast)) range len(bst) - len(ast) len(bst) len bst len(ast) len ast anst += bst[2 + i] anst bst[2 + i] bst 2 + i 2 i for i in range(len(ast) - 2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:], 2)
             i range(len(ast) - 2) range len(ast) - 2 len(ast) len ast 2 if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                 ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i] ast[-len(ast) + 2 + i] ast -len(ast) + 2 + i -len(ast) + 2 -len(ast) len(ast) len ast 2 i bst[-len(ast) + 2 + i] bst -len(ast) + 2 + i -len(ast) + 2 -len(ast) len(ast) len ast 2 i anst += '0' anst '0' anst += '1' anst '1' aa = int(anst[2:], 2) aa int(anst[2:], 2) int anst[2:] anst 2: 2 2 print(aa - 1) print aa - 1 aa 1 if (b-a) % 4 == 2:
            print(a-1)
        else:
            print(a) (b-a) % 4 == 2 (b-a) % 4 b-a b a 4 2 print(a-1) print a-1 a 1 print(a) print a def S(): return sys.stdin.readline().rstrip() def S(): return sys.stdin.readline().rstrip() S def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) LI anst += bst[2 + i] bst[2 + i] anst ast = bin(a) bin(a) ast b = MI() MI() b ast = bin(a) bin(a) ast aa = int(anst[2:], 2) int(anst[2:], 2) aa bst = bin(b) bin(b) bst aa = int(anst[2:],2) int(anst[2:],2) aa bst = bin(b) bin(b) bst anst += '1' '1' anst anst = '0b' '0b' anst def I(): return int(sys.stdin.readline().rstrip()) def I(): return int(sys.stdin.readline().rstrip()) I anst += '0' '0' anst def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)] def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)] LS anst += bst[2+i] bst[2+i] anst anst += '0' '0' anst a,b = MI() MI() a anst = '0b' '0b' anst def MI(): return map(int,sys.stdin.readline().rstrip().split()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) MI anst += '1' '1' anst
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)]

a,b = MI()

if a % 2 == 0:
    if b % 2 == 0:
        if (b-a) % 4 == 2:
            print(b + 1)
        else:
            print(b)
    else:
        if (b-a) % 4 == 1:
            print(1)
        else:
            print(0)
else:
    if b % 2 == 0:
        if (b-a) % 4 == 1:
            bst = bin(b)
            ast = bin(a)
            anst = '0b'
            if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):

                    anst += bst[2+i]
            for i in range(len(ast) -2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:],2)
            print(aa)

        else:
            bst = bin(b)
            ast = bin(a)
            anst = '0b'
            if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):
                    anst += bst[2 + i]
            for i in range(len(ast) - 2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:], 2)
            print(aa - 1)
    else:
        if (b-a) % 4 == 2:
            print(a-1)
        else:
            print(a)