#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, cnt = 0;
  bool mark = false;
  cin >> n >> m;
  while (n--) {
    for (int i = 0; i < 2 * m; i++) {
      bool x;
      cin >> x;
      if (!(i % 2)) mark = false;
      if (x)
        if (!mark)
          cnt++, mark = true;
        else
          mark = false;
    }
  }
  cout << cnt;
  return 0;
}
