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) $ [a..a+e-1]                                                                
  print $ d + fromIntegral f