import Control.Applicative
import Control.Monad

main = do
  [n,c] <- map read . words <$> getLine :: IO [Int]
  xvs <- replicateM n $ readIntPair . words <$> getLine
  print $ solve 0 0 []  xvs --sortedBy fst  

readIntPair :: [String] -> (Int,Int)
readIntPair =  \[a,b]->(read a,read b)

solve :: Int -> Int -> [Int] -> [(Int,Int)] -> Int
solve _  _ acc [] = maximum acc
solve locate now acc ((x,v) :xvs)=
  solve x now' (now' : acc)  xvs
  where
    comsume' = locate - x
    get = v
    now' =  now + comsume' + get
  
  
