#include <bits/stdc++.h>
using namespace std;
int U[1010][1010], L[1010][1010], M[1010][1010];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> M[i][j];
      L[i][j] = L[i][j - 1];
      U[i][j] = U[i - 1][j];
      if (M[i][j]) L[i][j]++, U[i][j]++;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (!M[i][j]) {
        if (L[i][j]) ans++;
        if (U[i][j]) ans++;
        if (L[i][m] - L[i][j]) ans++;
        if (U[n][j] - U[i][j]) ans++;
      }
    }
  }
  return cout << ans << '\n', 0;
}
