#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9 + 10;
const int N = 1010;
int n, m;
int d[N][N];
int row[2][N], col[2][N];
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> d[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (d[i][j]) {
        if (!row[1][i]) row[1][i] = j;
        row[2][i] = j;
      }
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
      if (d[j][i]) {
        if (!col[1][i]) col[1][i] = j;
        col[2][i] = j;
      }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (!d[i][j]) {
        int pred = ans;
        if (row[1][i] && row[1][i] < j) ans++;
        if (row[2][i] && row[2][i] > j) ans++;
        if (col[1][j] && col[1][j] < i) ans++;
        if (col[2][j] && col[2][j] > i) ans++;
      }
  cout << ans;
  return 0;
}
