#include <bits/stdc++.h>
using namespace std;
void swap(int &a, int &b) {
  int temp = a;
  a = b, b = temp;
}
int main(int argc, char const *argv[]) {
  int C = 0, N, M, i, j, k, ans, aA, bB;
  cin >> N >> M;
  for (i = 0; i < N; i++) {
    for (j = 0; j < M; j++) {
      cin >> aA >> bB;
      C += (aA | bB);
    }
  }
  cout << C << endl;
  return 0;
}
