# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

ll = inputs[0][0]
rr = inputs[0][1]

# body
if $debugFlag
  p ll
  p rr
end

def calc(l, r)
  return l if l == r
  if r-l < 8192
    xsum = 0
    for i in l..r
      xsum ^= i
    end
    return xsum
  end
  
  tmp = 1
  while tmp <= r
    tmp *= 2
  end
  if $debugFlag
    print "l: #{l}\n"
    print "r: #{r}\n"
  end

  if tmp - 1 == r
    tmp2 = 1
    diff = r - l
    while tmp2 <= diff
      tmp2 *= 2
    end
    return calc(l, r - tmp2/2)
  end

  if l == 0
    return calc(tmp/2, r)
  end
  
  return calc(r+1, tmp-1) ^ calc(0, l-1)
end


puts calc(ll, rr)
