#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int64_t n, m;
  cin >> n >> m;
  vector<int64_t> right(n, -1), left(n, LLONG_MAX), down(m, -1),
      up(m, LLONG_MAX);
  int64_t a[n][m];
  for (int64_t i = 0; i < n; ++i) {
    for (int64_t j = 0; j < m; ++j) {
      cin >> a[i][j];
      if (a[i][j]) {
        right[i] = max(right[i], j);
        left[i] = min(left[i], j);
      }
    }
  }
  for (int64_t j = 0; j < m; ++j) {
    for (int64_t i = 0; i < n; ++i) {
      if (a[i][j]) {
        down[j] = max(down[j], i);
        up[j] = min(up[j], i);
      }
    }
  }
  int64_t ans = 0;
  for (int64_t i = 0; i < n; ++i) {
    for (int64_t j = 0; j < m; ++j) {
      if (!a[i][j]) {
        ans += j < right[i];
        ans += j > left[i];
        ans += i < down[j];
        ans += i > up[j];
      }
    }
  }
  cout << ans;
}
