#include <bits/stdc++.h>
using namespace std;
const int oo = int(2e9) + 9;
const double eps = 1e-9;
const double pi = 3.14159265358979323846264338327950;
int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      int x, y;
      cin >> x >> y;
      bool f = true;
      if (x || y) f = false;
      ans += f;
    }
  cout << n * m - ans << endl;
  return 0;
}
