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