#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int a[n][2 * m];
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2 * m; j++) {
      cin >> a[i][j];
      if (j % 2) {
        if (a[i][j] == 1 || a[i][j - 1] == 1) cnt++;
      }
    }
  }
  cout << cnt;
}
