{-# LANGUAGE BangPatterns #-}

main :: IO ()
main = do
    [n, x] <- fmap read . words <$> getLine
    as     <- fmap read . words <$> getLine
    answer $ solve x as

type Answer = Int
answer :: Answer -> IO ()
answer = print

solve :: Int -> [Int] -> Answer
solve x = inner 0 x
  where
    inner !n !k aas
      | null as   = n + m
      | otherwise = inner (n + m) (x + m - a) as
      where
        (a : as) = aas
        m = max 0 (a - k)
