eolymp
bolt
Try our new interface for solving problems
Problems

Theater

Theater

The theater series \textbf{M}×\textbf{N} sites each. Given two matrices: the first recorded cost of tickets, and the second tells you what tickets have been sold, and what - no (\textbf{1} - corresponding ticket sold, \textbf{0} - not sold). Vasya with the company wants to go to the theater, but they are willing to buy only the cheapest, which are only in the theater. Determine what the maximum possible size of the company, which may go to the theater (in other words, how many more cheap tickets remained on sale). \InputFile Set the number of first \textbf{N} then the number of \textbf{M}. then set the ticket price matrix (\textbf{N} rows by \textbf{M} numbers, each number an integer from \textbf{0} to \textbf{10000}). Further, given a matrix of tickets sold (again \textbf{N} rows by \textbf{M} numbers). \textbf{N} and \textbf{M} do not exceed \textbf{100}. \OutputFile Display the desired number.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3 4
1 100 100 1
1 5 5 1
2 2 3 2

1 0 1 1
0 1 1 0
0 0 1 0
Output example #1
2
Source Stage II Ukrainian School Olympiad 2011-2012, Berdichev