f::(Int,Int)->Int
f (x,y)=x*y

f2::String->[Int]->Int
f2 xs ys=let zs=zip (map read (words xs)::[Int]) ys
         in sum (map f zs)

main = do
       e1<-getLine
       e2<-getLine
       es<-getContents
       let xs=lines es
           ys=map read (words e2)::[Int]
           (_:_:c:[])=map read (words e1)::[Int]
       print $ length [1|e<-xs,(f2 e ys)+c>0]