#include <bits/stdc++.h>
int main() {
  int i, j, k, l, a, b, c, sum, co, t, ans, n, m;
  while (scanf("%d%d", &n, &m) == 2) {
    ans = 0;
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        scanf("%d%d", &a, &b);
        if (a == 1 || b == 1) ans++;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
