#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
a,b=map(int,input().split())
if a==b:
  print(a)
  exit()
if a==0:
  i=0
  resb=0
  while True:
    if i==0:
      if ((b+1)//2)%2==1:
        resb+=1
      i+=1
      continue
    if 2**i>b+1:
        break
    if ((b+1)%(2**i))%2==1 and ((b+1)//(2**i))%2==1:
        resb+=2**i
    i+=1
  print(resb)
  exit()
  
n_b=b.bit_length()
n_a=(a-1).bit_length()
i=0
res=0

while True:
    if i==0:
      if (a//2)%2==1:
        res+=1
      i+=1
      continue
    if 2**i>a:
        break
    if (a%(2**i))%2==1 and (a//(2**i))%2==1:
        res+=2**i
    i+=1
i=0
resb=0
while True:
  if i==0:
    if ((b+1)//2)%2==1:
      resb+=1
    i+=1
    continue
  if 2**i>b+1:
        break
  if ((b+1)%(2**i))%2==1 and ((b+1)//(2**i))%2==1:
        resb+=2**i
  i+=1
print(res^resb) from collections import deque 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 a==0:
  i=0
  resb=0
  while True:
    if i==0:
      if ((b+1)//2)%2==1:
        resb+=1
      i+=1
      continue
    if 2**i>b+1:
        break
    if ((b+1)%(2**i))%2==1 and ((b+1)//(2**i))%2==1:
        resb+=2**i
    i+=1
  print(resb)
  exit()
   a==0 a 0 i=0 i 0 resb=0 resb 0 while True:
    if i==0:
      if ((b+1)//2)%2==1:
        resb+=1
      i+=1
      continue
    if 2**i>b+1:
        break
    if ((b+1)%(2**i))%2==1 and ((b+1)//(2**i))%2==1:
        resb+=2**i
    i+=1
   True if i==0:
      if ((b+1)//2)%2==1:
        resb+=1
      i+=1
      continue
     i==0 i 0 if ((b+1)//2)%2==1:
        resb+=1
       ((b+1)//2)%2==1 ((b+1)//2)%2 (b+1)//2 b+1 b 1 2 2 1 resb+=1 resb 1 i+=1 i 1 continue if 2**i>b+1:
        break
     2**i>b+1 2**i 2 i b+1 b 1 break if ((b+1)%(2**i))%2==1 and ((b+1)//(2**i))%2==1:
        resb+=2**i
     ((b+1)%(2**i))%2==1 and ((b+1)//(2**i))%2==1 ((b+1)%(2**i))%2==1 ((b+1)%(2**i))%2 (b+1)%(2**i) b+1 b 1 2**i 2 i 2 1 ((b+1)//(2**i))%2==1 ((b+1)//(2**i))%2 (b+1)//(2**i) b+1 b 1 2**i 2 i 2 1 resb+=2**i resb 2**i 2 i i+=1 i 1 print(resb) print resb exit() exit n_b=b.bit_length() n_b b.bit_length() b.bit_length b bit_length n_a=(a-1).bit_length() n_a (a-1).bit_length() a-1).bit_length a-1 a 1 bit_length i=0 i 0 res=0 res 0 while True:
    if i==0:
      if (a//2)%2==1:
        res+=1
      i+=1
      continue
    if 2**i>a:
        break
    if (a%(2**i))%2==1 and (a//(2**i))%2==1:
        res+=2**i
    i+=1 True if i==0:
      if (a//2)%2==1:
        res+=1
      i+=1
      continue
     i==0 i 0 if (a//2)%2==1:
        res+=1
       (a//2)%2==1 (a//2)%2 a//2 a 2 2 1 res+=1 res 1 i+=1 i 1 continue if 2**i>a:
        break
     2**i>a 2**i 2 i a break if (a%(2**i))%2==1 and (a//(2**i))%2==1:
        res+=2**i
     (a%(2**i))%2==1 and (a//(2**i))%2==1 (a%(2**i))%2==1 (a%(2**i))%2 a%(2**i) a 2**i 2 i 2 1 (a//(2**i))%2==1 (a//(2**i))%2 a//(2**i) a 2**i 2 i 2 1 res+=2**i res 2**i 2 i i+=1 i 1 i=0 i 0 resb=0 resb 0 while True:
  if i==0:
    if ((b+1)//2)%2==1:
      resb+=1
    i+=1
    continue
  if 2**i>b+1:
        break
  if ((b+1)%(2**i))%2==1 and ((b+1)//(2**i))%2==1:
        resb+=2**i
  i+=1 True if i==0:
    if ((b+1)//2)%2==1:
      resb+=1
    i+=1
    continue
   i==0 i 0 if ((b+1)//2)%2==1:
      resb+=1
     ((b+1)//2)%2==1 ((b+1)//2)%2 (b+1)//2 b+1 b 1 2 2 1 resb+=1 resb 1 i+=1 i 1 continue if 2**i>b+1:
        break
   2**i>b+1 2**i 2 i b+1 b 1 break if ((b+1)%(2**i))%2==1 and ((b+1)//(2**i))%2==1:
        resb+=2**i
   ((b+1)%(2**i))%2==1 and ((b+1)//(2**i))%2==1 ((b+1)%(2**i))%2==1 ((b+1)%(2**i))%2 (b+1)%(2**i) b+1 b 1 2**i 2 i 2 1 ((b+1)//(2**i))%2==1 ((b+1)//(2**i))%2 (b+1)//(2**i) b+1 b 1 2**i 2 i 2 1 resb+=2**i resb 2**i 2 i i+=1 i 1 print(res^resb) print res^resb res resb resb+=1 1 resb a,b=map(int,input().split()) map(int,input().split()) a i+=1 1 i i=0 0 i i+=1 1 i resb=0 0 resb i=0 0 i i+=1 1 i n_a=(a-1).bit_length() (a-1).bit_length() n_a i+=1 1 i n_b=b.bit_length() b.bit_length() n_b i+=1 1 i resb+=2**i 2**i resb resb+=2**i 2**i resb i=0 0 i res+=1 1 res res=0 0 res res+=2**i 2**i res resb+=1 1 resb b=map(int,input().split()) map(int,input().split()) b resb=0 0 resb i+=1 1 i
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
a,b=map(int,input().split())
if a==b:
  print(a)
  exit()
if a==0:
  i=0
  resb=0
  while True:
    if i==0:
      if ((b+1)//2)%2==1:
        resb+=1
      i+=1
      continue
    if 2**i>b+1:
        break
    if ((b+1)%(2**i))%2==1 and ((b+1)//(2**i))%2==1:
        resb+=2**i
    i+=1
  print(resb)
  exit()
  
n_b=b.bit_length()
n_a=(a-1).bit_length()
i=0
res=0

while True:
    if i==0:
      if (a//2)%2==1:
        res+=1
      i+=1
      continue
    if 2**i>a:
        break
    if (a%(2**i))%2==1 and (a//(2**i))%2==1:
        res+=2**i
    i+=1
i=0
resb=0
while True:
  if i==0:
    if ((b+1)//2)%2==1:
      resb+=1
    i+=1
    continue
  if 2**i>b+1:
        break
  if ((b+1)%(2**i))%2==1 and ((b+1)//(2**i))%2==1:
        resb+=2**i
  i+=1
print(res^resb)