#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, m, a, b, count = 0;
  ;
  cin >> n >> m;
  while (cin >> a >> b) {
    if (a == 1 || b == 1) {
      count++;
    }
  }
  cout << count;
}
signed main() {
  long long test = 1;
  while (test--) {
    solve();
  }
}
