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