import Control.Applicative
import Data.Maybe
import Debug.Trace

data SegTree a = Leaf a | Tree Int a (SegTree a) (SegTree a) deriving (Show)

main :: IO ()
main = do
        [n,s] <- map read.words<$>getLine
        list <- map read.words<$>getLine
        let tree = fromList list
            result = calcSmallestWindow tree s
        case result of
          Nothing -> print 0
          (Just x) -> print x

size (Leaf x) = 1
size (Tree n _ _ _) = n

value (Leaf x) = x
value (Tree _ x _ _) = x

left (Tree _ _ t _) = t
right (Tree _ _ _ t) = t

fromList :: Num a => [a] -> SegTree a
fromList xs = fl n xs
    where n = length xs

fl :: Num a => Int -> [a] -> SegTree a
fl n [x] = Leaf x
fl n xs = Tree n v leftT rightT
    where n' = n `div` 2
          (xsL, xsR) = splitAt n' xs
          leftT = fl n' xsL
          rightT = fl (n-n') xsR
          v = value leftT + value rightT

getSum _ _ (Leaf v) = v
getSum s t tr
  | n < s = getSum (s-n) (t-n) (right tr)
  | n >= t = getSum s t (left tr)
  | t-s+1 == size tr = value tr
  | otherwise = lv + rv
  where n = size tr `div` 2
        lv = getSum s n (left tr)
        rv = getSum 0 (t-n) (right tr)

calcSmallestWindow :: SegTree Int -> Int -> Maybe Int
calcSmallestWindow (Leaf v) s = if v < s then Nothing else Just 1
calcSmallestWindow tr s
  | goukei < s = Nothing
  | otherwise   = Just minWin
    where goukei = value tr
          minWin = size tr `min` lwin `min` rwin
          lwin = fromMaybe maxBound $ calcSmallestWindow (left tr) s
          rwin = fromMaybe maxBound $ calcSmallestWindow (right tr) s

