#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  int a[n][m];
  vector<int> rf(n, -1), rl(n, -1), cf(m, -1), cl(m, -1);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
      if (a[i][j]) {
        rl[i] = j;
        cl[j] = i;
        if (rf[i] == -1) rf[i] = j;
        if (cf[j] == -1) cf[j] = i;
      }
    }
  long long int cnt = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (a[i][j] == 0) {
        if (cf[j] < i and cf[j] != -1) cnt++;
        if (rf[i] < j and rf[i] != -1) cnt++;
        if (cl[j] > i) cnt++;
        if (rl[i] > j) cnt++;
      }
  cout << cnt << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long int t = 1;
  while (t--) solve();
}
