program main
  implicit none
  integer(8) :: a, b, x
  read *, a, b, x
  print "(i0)", f(b) - f(a - 1)
  contains
  integer(8) function f(n)
    integer(8), intent(in) :: n
    if (n == -1) then
      f = 0
    else
      f = n / x + 1
    end if
  end function f
end program main
