main :: IO ()                                                                                                              
main = do                                                                                                                  
  [a,b,x] <- map read . words <$> getLine :: IO [Integer]                                                                  
  let c = b - a + 1                                                                                                        
      d = c `div` x                                                                                                        
      e = c `mod` x                                                                                                        
      f = length . filter ((==0) . flip mod x) $ takeN e [a..a+e-1]                                                        
  print $ d + fromIntegral f                                                                                               
                                                                                                                           
takeN :: Integer -> [a] -> [a]                                                                                             
takeN _ [] = []                                                                                                            
takeN n (x:xs) = x : takeN (n-1) xs