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