#include <bits/stdc++.h>
using namespace std;
bool comp(const pair<long long, long long> &a,
          const pair<long long, long long> &b) {
  return a.second < b.second;
}
int main() {
  long long n, m, ans = 0;
  cin >> n >> m;
  long long a[n][m];
  long long dp1[n + 1][m + 2], dp2[n + 2][m + 1];
  memset(dp1, 0, sizeof(dp1));
  memset(dp2, 0, sizeof(dp2));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 1)
        dp1[i + 1][j + 1] = 1 + dp1[i + 1][j];
      else
        dp1[i + 1][j + 1] = dp1[i + 1][j];
    }
  }
  for (long long j = 0; j < m; j++) {
    for (long long i = 0; i < n; i++) {
      if (a[i][j] == 1)
        dp2[i + 1][j + 1] = 1 + dp2[i][j + 1];
      else
        dp2[i + 1][j + 1] = dp2[i][j + 1];
    }
  }
  for (long long i = 1; i < n + 1; i++) {
    for (long long j = 1; j < m + 1; j++) {
      if (a[i - 1][j - 1] == 0) {
        if (dp1[i][j - 1]) ans++;
        if (dp1[i][m] > dp1[i][j]) ans++;
        if (dp2[i - 1][j]) ans++;
        if (dp2[n][j] > dp2[i][j]) ans++;
      }
    }
  }
  cout << ans;
}
