
foo :: Int -> [Int] -> Int -> Int -> Int
foo _ [] _ memo = memo
foo pos (x:xs) limit memo =
  if pos > limit then memo else foo (pos+x) xs limit (memo+1)

main = do
  ints <- map read . words <$> getLine :: IO [Int]
  let x = last ints
  steps <- map read . words <$> getLine :: IO [Int]
  print $ foo 0 steps x 0

