program xor_world
  implicit none
  integer(8) :: a, b
  read(*,*) a, b
  write(*,'(i0)') f(a,b)
contains
  recursive function f(a,b) result(y)
    implicit none
    integer(8), intent(in) :: a, b
    integer(8)             :: y
    if (a.ne.0_8) then
      y = xor(f(0_8,a-1),f(0_8,b))
      return
    end if
    if (mod(b,2_8).eq.1) then
      y = mod((b+1_8)/2_8,2_8)
    else
      y = xor(mod(b/2_8,2_8),b)
    end if
    return
  end function f
end program xor_world