import math
A, B = map(int,input().split())
if A == B:
    print(A)
else:
    LA = []
    LB = []
    for i in range(int(math.log2(A))+1):
        P = A % (2**(i+1))
        Q = P % (2**i)
        R = (P-Q)//(2**i)
        LA.append(R)
    for i in range(int(math.log2(B))+1):
        P = B % (2**(i+1))
        Q = P % (2**i)
        R = (P-Q)//(2**i)
        LB.append(R)
    LS = []
    def Q(a,b):
        return (a%2,b%2)
    if A == B-1:
        if Q(A,B) == (0,1):
            print(1)
        else:
            LS.append(1)
            if len(LA) == len(LB):
                for i in range(1,len(LA)):
                    LS.append((LA[i]+LB[i])%2)
            else:
                for i in range(1,len(LA)):
                    LS.append(LA[i])
                LS.append(LB[-1])
            ANS = 0
            for i in range(len(LS)):
                ANS += (2**i)*LS[i]
            print(ANS)
    else:
        if Q(A,B) == (0,0):
            if (B-A+1)%4 ==1:
                print(B)
            else:
                print(B+1)
        elif Q(A,B) == (0,1):
            if (B-A+1)%4 == 0:
                print(0)
            else:
                print(1)
        elif Q(A,B) == (1,0):
            if (B-A+1)%4 == 0:
                LS.append(0)
            else:
                LS.append(1)
            if len(LA) > 1:
                for i in range(1,len(LA)):
                    LS.append((LA[i]+LB[i])%2)
            if len(LB) > len(LA):
                for i in range(len(LA),len(LB)):
                    LS.append(LB[i])
            ANS = 0
            for i in range(len(LS)):
                ANS += (2**i)*LS[i]
            print(ANS)
        else:
            if (B-A+1)%4 ==1:
                print(A)
            else:
                print(A-1)

### FIXED CODE ###

import math
A, B = map(int,input().split())
if A == 0:
    if B % 4 ==0:
        print(B)
    elif B % 4 == 1:
        print(1)
    elif B % 4 == 2:
        print(B+1)
    else:
        print(0)
elif A == B:
    print(A)
else:
    LA = []
    LB = []
    for i in range(int(math.log2(A))+1):
        P = A % (2**(i+1))
        Q = P % (2**i)
        R = (P-Q)//(2**i)
        LA.append(R)
    for i in range(int(math.log2(B))+1):
        P = B % (2**(i+1))
        Q = P % (2**i)
        R = (P-Q)//(2**i)
        LB.append(R)
    LS = []
    def Q(a,b):
        return (a%2,b%2)
    if A == B-1:
        if Q(A,B) == (0,1):
            print(1)
        else:
            LS.append(1)
            if len(LA) == len(LB):
                for i in range(1,len(LA)):
                    LS.append((LA[i]+LB[i])%2)
            else:
                for i in range(len(LA)):
                    LS.append(1)
            ANS = 0
            for i in range(len(LS)):
                ANS += (2**i)*LS[i]
            print(ANS)
    else:
        if Q(A,B) == (0,0):
            if (B-A+1)%4 ==1:
                print(B)
            else:
                print(B+1)
        elif Q(A,B) == (0,1):
            if (B-A+1)%4 == 0:
                print(0)
            else:
                print(1)
        elif Q(A,B) == (1,0):
            if (B-A+1)%4 == 0:
                LS.append(0)
            else:
                LS.append(1)
            if len(LA) > 1:
                for i in range(1,len(LA)):
                    LS.append((LA[i]+LB[i])%2)
            if len(LB) > len(LA):
                for i in range(len(LA),len(LB)):
                    LS.append(LB[i])
            ANS = 0
            for i in range(len(LS)):
                ANS += (2**i)*LS[i]
            print(ANS)
        else:
            if (B-A+1)%4 == 1:
                print(A)
            else:
                print(A-1)