#include <bits/stdc++.h>
using namespace std;
bool compare(int a, int b) { return a < b; }
bool compare1(int a, int b) { return a > b; }
void solve() {}
int main() {
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  int flat;
  int count = 0;
  for (int i = (int)0; i < (int)n; i++) {
    for (int j = (int)1; j < (int)2 * m + 1; j++) {
      scanf("%d", &flat);
      if (j % 2 == 1) {
        if (flat == 1) {
          count++;
          ++j;
          scanf("%d", &flat);
        } else {
          ++j;
          scanf("%d", &flat);
          if (flat == 1) count++;
        }
      } else {
        if (flat == 1) count++;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}
