(* O(|xs|) *)
let list_count f = List.fold_left (fun n x -> if f x then n + 1 else n) 0

(* O(n * m) *)
let solve n m c bs as_s =
  list_count
    (fun a_s -> c + List.fold_left2 (fun sum a b -> sum + a * b) 0 a_s bs > 0)
    as_s

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

(* O(n) *)
let rec fold_btw f a i n = if i >= n then a else fold_btw f (f a i) (i + 1) n
let fold_int f a n = fold_btw f a 0 n

let _ =
  match read_ints () with
  | [n; m; c] ->
    let bs = read_ints () in
    fold_int
      (fun acc _ -> read_ints () :: acc)
      []
      n |> solve n m c bs |> string_of_int |> print_endline
  | _ -> ()