#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, e, f, g, h, i, j;
  int ar[1000];
  vector<int> v;
  cin >> a >> b;
  while (a--) {
    c = 0;
    d = 0;
    for (i = 0; i < 2 * b; i++) {
      cin >> e;
      c++;
      if (e == 1) {
        d = 1;
      }
      if (c % 2 == 0) {
        v.push_back(d);
        d = 0;
      }
    }
  }
  g = 0;
  for (i = 0; i < v.size(); i++) {
    g = g + v[i];
  }
  cout << g << endl;
  return 0;
}
