#include <bits/stdc++.h>
using namespace std;
char s[100005];
int main() {
  int n, m, a, b, r = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a >> b;
      r += (a | b);
    }
  }
  cout << r << endl;
  return 0;
}
