#include <bits/stdc++.h>
using namespace std;
int main() {
  int flat, floor, cnt = 0, arr[100000];
  cin >> flat >> floor;
  for (int j = 0; j < 2 * floor * flat; j++) {
    cin >> arr[j];
  }
  for (int j = 0; j < 2 * floor * flat; j++) {
    if ((arr[j] != arr[j + 1]) || (arr[j] == 1 && arr[j + 1] == 1)) {
      cnt++;
    }
    j++;
  }
  cout << cnt << endl;
  return 0;
}
