#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n][m], sumCol[1000][1000] = {}, sumRow[1000][1000] = {};
  int ans = 0;
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < m; ++j) {
      cin >> a[i][j];
      sumCol[i][j] += a[i][j] + ((j > 0) ? sumCol[i][j - 1] : 0);
      sumRow[i][j] += a[i][j] + ((i > 0) ? sumRow[i - 1][j] : 0);
    }
  }
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < m; ++j) {
      if (a[i][j] == 0) {
        if (j < m - 1 && sumCol[i][m - 1] > sumCol[i][j]) ++ans;
        if (i < n - 1 && sumRow[n - 1][j] > sumRow[i][j]) ++ans;
        if (j > 0 && sumCol[i][0] <= sumCol[i][j] && sumCol[i][j] != 0) ++ans;
        if (i > 0 && sumRow[0][j] <= sumRow[i][j] && sumRow[i][j] != 0) ++ans;
      }
    }
  }
  cout << ans;
  return 0;
}
