main = do
  li <- getLine
  let c = read $ last $ words li
  li <- getLine
  let bs = map read $ words li
  co <- getContents
  let ass = map (map read . words) $ lines co
  print $ compute c bs ass

compute :: Int -> [Int] -> [[Int]] -> Int
compute c bs ass = length [() | as <- ass, sum (zipWith (*) bs as) > negate c]