#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b, cnt = 0, i, j;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> a >> b;
      if (a == 1 || b == 1) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
