#include <bits/stdc++.h>
using namespace std;
int n, m, x[1000][1000], ans, l, r, ppl;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &x[i][j]);
    }
  }
  for (int i = 0; i < n; i++) {
    ppl = 0;
    l = m;
    r = 0;
    for (int j = 0; j < m; j++) {
      if (l == m && x[i][j] == 1) l = j;
      if (x[i][j]) {
        r = j;
        ppl++;
      }
    }
    if (l != m) ans += m - l - ppl + (r + 1 - ppl);
  }
  for (int j = 0; j < m; j++) {
    ppl = 0;
    l = n;
    r = 0;
    for (int i = 0; i < n; i++) {
      if (l == n && x[i][j] == 1) l = i;
      if (x[i][j]) {
        r = i;
        ppl++;
      }
    }
    if (l != n) ans += n - l - ppl + (r + 1 - ppl);
  }
  printf("%d", ans);
  return 0;
}
