import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B

main = do
  [_,x] <- map read . words <$> getLine
  as <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
  print (candies x as)

candies x = fst . foldl' (eat x) (0,0)

eat x (acc,rest) a = let n = max 0 (rest+a-x) in (acc+n, a-n)