a, b = gets.split.map(&:to_i)

$bits = Math.log2(b).ceil

def func(n)
  1.upto($bits).map do |i|
    if i == 1
      if [1, 2].include?(n % 4) then 1 else 0 end
    else
      case n % (2**i)
      when ->(x) {((x >= 2**(i-1))) && (x % 2 == 0)}
        1
      else
        0
      end
    end
  end.reverse.join('').to_i(2)
end

ans = func(a-1) ^ func(b)

if b == 2**$bits
  ans ^= b
end

puts ans
