def sum_xor(n)
  n = n+1
  ret = 0
  ret += 1 if [2, 3].include?(n % 4)
  (1...n.bit_length).each{|i|
    wk = n % (2<<i)
    if wk > 1<<i then
      ret += (1<<i) if (wk - (1<<i)).odd?
    end
  }
  ret
end

A, B = gets.chomp.split(" ").map(&:to_i)

puts sum_xor(B) ^ sum_xor(A-1)
