#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long pw(long long a, long long b) {
  long long r = 1;
  while (b > 0) {
    if (b & 1) {
      r = (r * a) % MOD;
    }
    b = b >> 1;
    a = (a * a) % MOD;
  }
  return (r) % MOD;
}
int in[1010][1010], rc[1010][1010] = {{}}, cr[1010][1010] = {{}};
int main() {
  int n, m;
  scanf("%d", &n), scanf("%d", &m);
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < m + 1; j++) {
      scanf("%d", &in[i][j]);
      rc[i][j] = in[i][j] + rc[i][j - 1];
      cr[j][i] = in[i][j] + cr[j][i - 1];
    }
  }
  int ans = 0, l, r, u, d;
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < m + 1; j++) {
      if (!in[i][j]) {
        l = rc[i][j] - rc[i][0];
        r = rc[i][m] - rc[i][j];
        u = cr[j][i] - cr[j][0];
        d = cr[j][n] - cr[j][i];
        if (l > 0) ans++;
        if (r > 0) ans++;
        if (u > 0) ans++;
        if (d > 0) ans++;
      }
    }
  }
  printf("%d", ans);
  printf("\n");
  return 0;
}
