#include <bits/stdc++.h>
using namespace std;
int n, m;
int atas0[1010], atas1[1010], kiri0[1010], kiri1[1010];
long long ans;
int main() {
  int i, j, x;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%d", &x);
      if (x) {
        ans += kiri0[i];
        kiri0[i] = 0;
        ans += atas0[j];
        atas0[j] = 0;
        atas1[j]++;
        kiri1[i]++;
      } else {
        if (kiri1[i] > 0) ans++;
        if (atas1[j] > 0) ans++;
        atas0[j]++;
        kiri0[i]++;
      }
    }
  }
  printf("%d\n", ans);
}
