#include <bits/stdc++.h>
using namespace std;
bool u[2000][2000] = {0}, d[2000][2000] = {0}, l[2000][2000] = {0},
     r[2000][2000] = {0};
bool a[2000][2000] = {0};
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      scanf("%d", &(a[i][j]));
      if (j > 0) l[i][j] = l[i][j - 1] || a[i][j - 1];
      if (i > 0) u[i][j] = u[i - 1][j] || a[i - 1][j];
    }
  for (int i = n - 1; i >= 0; i--)
    for (int j = m - 1; j >= 0; j--) {
      if (i < n - 1) d[i][j] = d[i + 1][j] || a[i + 1][j];
      if (j < m - 1) r[i][j] = r[i][j + 1] || a[i][j + 1];
    }
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 0 && r[i][j]) ans++;
      if (a[i][j] == 0 && l[i][j]) ans++;
      if (a[i][j] == 0 && u[i][j]) ans++;
      if (a[i][j] == 0 && d[i][j]) ans++;
    }
  cout << ans;
}
