#include <bits/stdc++.h>
using namespace std;
int II() {
  char c = getchar();
  while (c < '0') c = getchar();
  int n = c - 48;
  c = getchar();
  while (c >= '0') {
    n = n * 10 + c - 48;
    c = getchar();
  }
  return n;
}
long long int LL() {
  char c = getchar();
  while (c < '0') c = getchar();
  long long int n = c - 48;
  c = getchar();
  while (c >= '0') {
    n = n * 10 + c - 48;
    c = getchar();
  }
  return n;
}
int numbercol[1001], moreleft[1001], moreright[1001], numberrow[1001],
    moreup[1001], moredown[1001];
int main() {
  int N, M;
  N = II();
  M = II();
  for (int y = 1; y <= N; y++)
    for (int x = 1; x <= M; x++) {
      int u = II();
      if (u) {
        numbercol[x]++;
        numberrow[y]++;
        if (!moreleft[y]) moreleft[y] = x;
        moreright[y] = x;
        if (!moreup[x]) moreup[x] = y;
        moredown[x] = y;
      }
    }
  int sum = 0;
  for (int y = 1; y <= N; y++)
    if (numberrow[y]) sum += (moreright[y] - numberrow[y]);
  for (int y = 1; y <= N; y++)
    if (numberrow[y]) sum += (M - moreleft[y] + 1 - numberrow[y]);
  for (int x = 1; x <= M; x++)
    if (numbercol[x]) sum += (moredown[x] - numbercol[x]);
  for (int x = 1; x <= M; x++)
    if (numbercol[x]) sum += (N - moreup[x] + 1 - numbercol[x]);
  printf("%d\n", sum);
}
