a, b = gets.chomp.split(' ').map(&:to_i)
num_of_one = []
v = b.to_s(2)
keta = v.length
b.downto(a) do |i|
  tmp = i.to_s(2).split('')
  tmp.each_with_index do |v, i|
    if v == "1"
      if keta > tmp.length
        num_of_one << i + (keta - tmp.length)
      else
        num_of_one << i 
      end
    end
  end
end
hmp = Array.new(keta, 0)
num_of_one.each do |num|
  hmp[num] += 1
end
str = []
hmp.each do |num|
  if num % 2 == 0
    str.push(0)
  else
    str.push(1)
  end
end
puts str.join().to_i(2)