#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int ans = 0, a, b;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf("%d%d", &a, &b);
      ans += a | b;
    }
  }
  printf("%d\n", ans);
  return 0;
}
