#include <bits/stdc++.h>
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
void solve() {
  int n, m, ans = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      int x, y;
      scanf("%d%d", &x, &y);
      ans += x | y;
    }
  printf("%d\n", ans);
}
int main() {
  solve();
  return 0;
}
