def xor_sum(a)
  (0..40).map{|i| include1_num(a,i)}
end

def include1_num(a,i)
  (((a + 1) / 2 ** (i + 1)) * (2 ** i) + [(a + 1) % (2 ** (i + 1)) - 2 ** i,0].max) % 2
end
a,b = gets.chomp.split(' ').map(&:to_i)
num = 0
(0..40).each do |i|
  num += 2 ** i if xor_sum(a - 1)[i] != xor_sum(b)[i] 
end
puts num