#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, y, x, c = 0;
  cin >> n >> m;
  int a[n][m * 2];
  for (x = 0; x < n; x++) {
    for (y = 0; y < m * 2; y++) {
      cin >> a[x][y];
    }
  }
  for (x = 0; x < n; x++) {
    for (y = 0; y < m * 2; y++) {
      if (y % 2 != 0)
        if (a[x][y] == 1 || a[x][y - 1] == 1) c++;
    }
  }
  cout << c << endl;
  return 0;
}
