import Data.List
main = do
  [n,x] <- map read . words <$> getLine
  a <- map read . words <$> getLine
  let b = sort a
      ac = scanl (+) 0 b
      ans =if sum a == x then n else min (n-1) $ (+) (-1) $ length $ filter (x>=) ac 
  print ans