def naive(a, b)
  tmp = a
  ans = a
  loop do
    tmp += 1
    return ans if tmp > b
    ans = ans ^ tmp
  end
end

def read_i
  gets.chomp.split(' ').map(&:to_i)
end

def next_bin(n)
  bin = 1
  loop do
    return bin if bin > n
    bin *= 2
  end
end

def prev_bin(n)
  next_bin(n) / 2
end

def f(a, b)
  bin1 = next_bin(a)
  bin2 = prev_bin(b)
  return naive(a, b) if bin1 >= bin2
  ln = naive(a, bin1 - 1)
  rn = naive(bin2, b)
  ans = ln ^ rn
  ans = ans ^ 1 if bin1 == 2
  ans
end

a, b = read_i
puts f(a, b)
