#include <iostream> #include <vector> using namespace std; int main() { int a, b; while (cin >> a ) { // 注意 while 处理多个 case if(a==0) break; cin>> b; vector<vector<int>> k1(a, vector<int> (b)); vector<vector<int>> k2(a, vector<int> (b)); vector<vector<int>> k3(a, vector<int> (b)); int k = 0; for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { cin >> k1[i][j]; } } for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { cin >> k2[i][j]; } } for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { k3[i][j] = k2[i][j] + k1[i][j]; } } for (int i = 0; i < a; i++) { int f = 0; for (int j = 0; j < b; j++) { if (k3[i][j]) { f = 1; break; } } if (f == 0) k++; } for (int j = 0; j < b; j++) { int f = 0; for (int i = 0; i < a; i++) { if (k3[i][j]) { f = 1; break; } } if (f == 0) k++; } cout << k << endl; } } // 64 位输出请用 printf("%lld")