#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const double EPS = 1e-7;
int main() {
  iostream::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int prev, res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2 * m; j++) {
      int x;
      cin >> x;
      if (j % 2 != 0) {
        if (x || prev) {
          res++;
        }
      }
      prev = x;
    }
  }
  cout << res;
  return 0;
}
