#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long arr[n + 1][m + 1], pre_h[n + 1][m + 1], pre_v[n + 1][m + 1];
  memset(pre_h, 0, sizeof(pre_h));
  memset(pre_v, 0, sizeof(pre_v));
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      cin >> arr[i][j];
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      pre_h[i][j] += pre_h[i][j - 1] + arr[i][j];
    }
  }
  for (long long i = 1; i <= m; i++) {
    for (long long j = 1; j <= n; j++) {
      pre_v[j][i] += pre_v[j - 1][i] + arr[j][i];
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      if (arr[i][j] == 0) {
        if (pre_h[i][j - 1] > 0) ans++;
        if (pre_h[i][m] - pre_h[i][j] > 0) ans++;
        if (pre_v[i - 1][j] > 0) ans++;
        if (pre_v[n][j] - pre_v[i][j] > 0) ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
