import Control.Applicative
import Data.List
import Data.Maybe
import Data.Array.IArray

main = do
  [n,s] <- map read.words<$>getLine
  list <- map read.words<$>getLine
  let arr = listArray (1,n) list
      (Just x) = minWindow s n arr
  print $ if x == maxBound then 0 else x

minWindow :: Int -> Int -> Array Int Int -> Maybe Int
minWindow s n arr = foldl' min' (Just maxBound).takeWhile (/= Nothing) $ map (\x -> minWindowFrom x s arr 0 x) [1..n]

minWindowFrom i s arr acc j
  | j > (snd.bounds $ arr) = Nothing
  | acc' >= s = Just (j - i + 1)
  | otherwise = minWindowFrom i s arr acc' (j+1)
  where acc' = acc + arr ! j

min' :: Ord a => Maybe a -> Maybe a -> Maybe a
min' n Nothing = n
min' Nothing n = n
min' n m       = min<$>n<*>m