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