program xor_world
  implicit none
  integer(8) :: a, b, i, length
  integer(8), allocatable :: m(:), n(:)
  read(*,*) a, b
  if (a.eq.0_8) then
    if (b.eq.0_8) then
      write(*,'(i0)') 0
      stop
    end if
    a = 1_8
  end if
  allocate(m(b-a+1_8))
  length = b-a+1_8
  do i = 1, length
    m(i) = a+i-1_8
  end do
  do while (length.gt.1_8)
    allocate(n(length/2_8))
    do i = 1_8, length/2_8
      n(i) = xor(m(2_8*i-1),m(2_8*i))
    end do
    if (mod(length,2).eq.1_8) then
      n(length/2_8) = xor(n(length/2_8),m(length))
    end if
    deallocate(m)
    allocate(m(length/2_8))
    m = n
    length = length/2_8
    deallocate(n)
  end do
  write(*,'(i0)') m(1)
end program xor_world