A,B = map(int,input().split())
b = list(bin(B))[2:]
b.reverse()
if A%2 == 0:
    if ((B-A)+1)%2 == 0:
        if ((B-A)+1)//2%2 == 0:
            print(0)
        else:
            print(1)
    else:
        if ((B-A)+1)//2%2 == 0:
            print(B)
        else:
            if b[0] == '0':
                print(B+1)
            else:
                print(B-1)
else:
    if ((B-A)+1)%2 == 0:
        if ((B-A)+1)//2%2 == 1:
            print(A^B)
        else:
            print(1^A^B)
    else:
        if ((B-A)+1)//2%2 == 0:
            print(A)
        else:
            print(A^1) A,B = map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B b = list(bin(B))[2:] b list(bin(B))[2:] (bin(B)) list bin(B) bin B 2: 2 b.reverse() b.reverse b reverse if A%2 == 0:
    if ((B-A)+1)%2 == 0:
        if ((B-A)+1)//2%2 == 0:
            print(0)
        else:
            print(1)
    else:
        if ((B-A)+1)//2%2 == 0:
            print(B)
        else:
            if b[0] == '0':
                print(B+1)
            else:
                print(B-1)
else:
    if ((B-A)+1)%2 == 0:
        if ((B-A)+1)//2%2 == 1:
            print(A^B)
        else:
            print(1^A^B)
    else:
        if ((B-A)+1)//2%2 == 0:
            print(A)
        else:
            print(A^1) A%2 == 0 A%2 A 2 0 if ((B-A)+1)%2 == 0:
        if ((B-A)+1)//2%2 == 0:
            print(0)
        else:
            print(1)
    else:
        if ((B-A)+1)//2%2 == 0:
            print(B)
        else:
            if b[0] == '0':
                print(B+1)
            else:
                print(B-1) ((B-A)+1)%2 == 0 ((B-A)+1)%2 (B-A)+1 B-A B A 1 2 0 if ((B-A)+1)//2%2 == 0:
            print(0)
        else:
            print(1)
     ((B-A)+1)//2%2 == 0 ((B-A)+1)//2%2 ((B-A)+1)//2 (B-A)+1 B-A B A 1 2 2 0 print(0) print 0 print(1) print 1 if ((B-A)+1)//2%2 == 0:
            print(B)
        else:
            if b[0] == '0':
                print(B+1)
            else:
                print(B-1) ((B-A)+1)//2%2 == 0 ((B-A)+1)//2%2 ((B-A)+1)//2 (B-A)+1 B-A B A 1 2 2 0 print(B) print B if b[0] == '0':
                print(B+1)
            else:
                print(B-1) b[0] == '0' b[0] b 0 '0' print(B+1) print B+1 B 1 print(B-1) print B-1 B 1 if ((B-A)+1)%2 == 0:
        if ((B-A)+1)//2%2 == 1:
            print(A^B)
        else:
            print(1^A^B)
    else:
        if ((B-A)+1)//2%2 == 0:
            print(A)
        else:
            print(A^1) ((B-A)+1)%2 == 0 ((B-A)+1)%2 (B-A)+1 B-A B A 1 2 0 if ((B-A)+1)//2%2 == 1:
            print(A^B)
        else:
            print(1^A^B)
     ((B-A)+1)//2%2 == 1 ((B-A)+1)//2%2 ((B-A)+1)//2 (B-A)+1 B-A B A 1 2 2 1 print(A^B) print A^B A B print(1^A^B) print 1^A^B 1^A 1 A B if ((B-A)+1)//2%2 == 0:
            print(A)
        else:
            print(A^1) ((B-A)+1)//2%2 == 0 ((B-A)+1)//2%2 ((B-A)+1)//2 (B-A)+1 B-A B A 1 2 2 0 print(A) print A print(A^1) print A^1 A 1 b = list(bin(B))[2:] list(bin(B))[2:] b A,B = map(int,input().split()) map(int,input().split()) A B = map(int,input().split()) map(int,input().split()) B
A,B = map(int,input().split())
b = list(bin(B))[2:]
b.reverse()
if A%2 == 0:
    if ((B-A)+1)%2 == 0:
        if ((B-A)+1)//2%2 == 0:
            print(0)
        else:
            print(1)
    else:
        if ((B-A)+1)//2%2 == 0:
            print(B)
        else:
            if b[0] == '0':
                print(B+1)
            else:
                print(B-1)
else:
    if ((B-A)+1)%2 == 0:
        if ((B-A)+1)//2%2 == 1:
            print(A^B)
        else:
            print(1^A^B)
    else:
        if ((B-A)+1)//2%2 == 0:
            print(A)
        else:
            print(A^1)