import Data.Bool
main = print . solve . map read . words =<< getLine

solve :: [Integer] -> Integer
solve [a,b,x] = bool n (n+1) $ m == 0 || a `rem` x > (a+m) `rem` x
    where
        r = b - a
        (n,m) = r `quotRem` x
