#include <bits/stdc++.h>
using namespace std;
bool Array[1005][1005];
int L[1005][1005], R[1005][1005], U[1005][1005], D[1005][1005];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> Array[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (Array[i][j] == 1) {
        if (L[i][j] == 0)
          L[i][j] = j;
        else
          L[i][j] = min(L[i][j], j);
        if (U[i][j] == 0)
          U[i][j] = i;
        else
          U[i][j] = min(U[i][j], i);
      } else {
        L[i][j] = L[i][j - 1];
        U[i][j] = U[i - 1][j];
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      if (Array[i][j] == 1) {
        if (R[i][j] == 0)
          R[i][j] = j;
        else
          R[i][j] = max(R[i][j], j);
        if (D[i][j] == 0)
          D[i][j] = i;
        else
          D[i][j] = max(D[i][j], i);
      } else {
        R[i][j] = R[i][j + 1];
        D[i][j] = D[i + 1][j];
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (Array[i][j] == 0) {
        if (L[i][j]) ans++;
        if (R[i][j]) ans++;
        if (U[i][j]) ans++;
        if (D[i][j]) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
