#include <bits/stdc++.h>
using namespace std;
int a[1005][1005], dp1[1005][1005], dp2[1005][1005];
int main() {
  int n, m;
  long long ans = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      dp1[i][j] = dp1[i][j - 1] + a[i][j];
      dp2[i][j] = dp2[i - 1][j] + a[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (!a[i][j]) {
        if (dp1[i][j] > 0) ans++;
        if (dp1[i][j] < dp1[i][m]) ans++;
        if (dp2[i][j] > 0) ans++;
        if (dp2[i][j] < dp2[n][j]) ans++;
      }
    }
  }
  cout << ans;
}
