#include <bits/stdc++.h>
using namespace std;
const double eps = 1E-8;
const int dx4[4] = {1, 0, 0, -1};
const int dy4[4] = {0, -1, 1, 0};
const int inf = 0x3f3f3f3f;
const int N = 1E5 + 7;
template <typename tp>
inline void read(tp &x) {
  x = 0;
  char c = getchar();
  bool f = 0;
  for (; c < '0' || c > '9'; f |= (c == '-'), c = getchar())
    ;
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar())
    ;
  if (f) x = -x;
}
int n, m;
int mp[1500][1500], pre1[N], pre2[N], pre3[N], pre4[N];
int sum[1500][1500], sum1[1500][1500];
inline void init() {
  for (int i = (1); i < (n + 1); i++) {
    for (int j = (1); j < (m + 1); j++) {
      scanf("%d", &mp[i][j]);
    }
  }
}
inline void pre() {
  for (int i = (1); i < (n + 1); i++) {
    for (int j = (1); j < (m + 1); j++) {
      sum[i][j] = sum[i][j - 1] + mp[i][j];
    }
  }
  for (int j = (1); j < (m + 1); j++) {
    for (int i = (1); i < (n + 1); i++) {
      sum1[i][j] = sum1[i - 1][j] + mp[i][j];
    }
  }
}
inline void work() {
  int ans = 0;
  for (int i = (1); i < (n + 1); i++) {
    for (int j = (1); j < (m + 1); j++) {
      if (mp[i][j] == 0) {
        if (sum[i][j]) ans++;
        if (sum[i][m] - sum[i][j]) ans++;
        if (sum1[i][j]) ans++;
        if (sum1[n][j] - sum1[i][j]) ans++;
      }
    }
  }
  printf("%d\n", ans);
}
int main() {
  scanf("%d%d", &n, &m);
  init();
  pre();
  work();
  return 0;
}
