#include <bits/stdc++.h>
using namespace std;
bool a[1000][1000];
int main() {
  ios::sync_with_stdio(false);
  int n, m, ans = 0;
  cin >> n >> m;
  bool tmp = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    tmp = 0;
    for (int j = 0; j < m; j++) {
      tmp = max(tmp, a[i][j]);
      if (a[i][j] == 0 && tmp) ans++;
    }
  }
  for (int i = 0; i < m; i++) {
    tmp = 0;
    for (int j = 0; j < n; j++) {
      tmp = max(tmp, a[j][i]);
      if (a[j][i] == 0 && tmp) ans++;
    }
  }
  for (int i = 0; i < n; i++) {
    tmp = 0;
    for (int j = m - 1; j >= 0; j--) {
      tmp = max(tmp, a[i][j]);
      if (a[i][j] == 0 && tmp) ans++;
    }
  }
  for (int i = 0; i < m; i++) {
    tmp = 0;
    for (int j = n - 1; j >= 0; j--) {
      tmp = max(tmp, a[j][i]);
      if (a[j][i] == 0 && tmp) ans++;
    }
  }
  cout << ans;
}
