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