main = do
    [a, b, x] <- map read . words <$> getLine :: IO [Integer]
    let t = (b - a + 1) `divMod` x
    print $ fst t + if null [ e | e <- [a .. a + snd t], e `mod` x == 0 ]
        then 0
        else 1
