#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j;
  cin >> n >> m;
  int a[n][m];
  memset(a, 0, sizeof(a));
  for (i = 0; i < n; ++i) {
    for (j = 0; j < m; ++j) cin >> a[i][j];
  }
  int ans = 0, left, right, top, down;
  for (i = 0; i < n; ++i) {
    left = 0;
    for (j = 0; j < m; ++j) {
      if (a[i][j])
        left = 1;
      else
        ans += left;
    }
    right = 0;
    for (j = m - 1; j >= 0; --j) {
      if (a[i][j])
        right = 1;
      else
        ans += right;
    }
  }
  for (i = 0; i < m; ++i) {
    top = 0;
    for (j = 0; j < n; ++j) {
      if (a[j][i])
        top = 1;
      else
        ans += top;
    }
    down = 0;
    for (j = n - 1; j >= 0; --j) {
      if (a[j][i])
        down = 1;
      else
        ans += down;
    }
  }
  cout << ans;
}
