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