#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> B(m, 0);
  vector<int> count(m, 0);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int res = 0;
    int coun = 0;
    for (int j = 0; j < m; j++) {
      int a;
      cin >> a;
      if (a == 1) {
        res = 1;
        ans += coun;
        coun = 0;
        ans += count[j];
        count[j] = 0;
        B[j] = 1;
      }
      if (a == 0) {
        coun += 1;
        count[j] += 1;
        if (res == 1) {
          ans += 1;
        }
        if (B[j] == 1) {
          ans += 1;
        }
      }
    }
  }
  cout << ans;
  return 0;
}
