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