#include <bits/stdc++.h>
int main() {
  int sleeping = 0;
  int n, m;
  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);
      sleeping += a | b;
    }
  }
  printf("%d\n", sleeping);
}
