#include <bits/stdc++.h>
using namespace std;
int x, y, n, m, i, j, sol;
int main() {
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      scanf("%d %d", &x, &y);
      if (x || y) sol++;
    }
  }
  printf("%d\n", sol);
}
