#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, c = 0;
  cin >> n >> m;
  while (n--) {
    int a[2 * m];
    for (i = 0; i < 2 * m; i++) {
      cin >> a[i];
    }
    for (i = 0; i < 2 * m; i = i + 2) {
      if (a[i] || a[i + 1] == 1) c++;
    }
  }
  cout << c << "\n";
}
