#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int counter = 0;
  int x, y;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> x >> y;
      if (x == 1 || y == 1) {
        counter++;
      }
    }
  }
  cout << counter << endl;
  return 0;
}
