#include <bits/stdc++.h>
using namespace std;
int a[1001][1001];
int citeste_rapid() {
  int nr = 0;
  char lit;
  while (cin.get(lit) && lit != ' ' && lit != '\n') nr = nr * 10 + lit - 48;
  return nr;
}
void actori_orizontala(int i, int &cnt, int n) {
  int j, ok = 0, nr = 0, nr1 = 0, cnt0 = 0;
  for (j = 1; j <= n; j++) {
    if (a[i][j] == 1) ok = 1;
    if (a[i][j] == 0 && ok == 1) ++cnt, cnt0++;
    if (ok == 0) nr++;
  }
  for (j = n; j >= 1; j--) {
    if (a[i][j] == 1)
      break;
    else
      nr1++;
  }
  cnt += cnt0 + nr - nr1;
}
void actori_verticala(int j, int &cnt, int n) {
  int i, ok = 0, nr = 0, nr1 = 0, cnt0 = 0;
  for (i = 1; i <= n; i++) {
    if (a[i][j] == 1) ok = 1;
    if (a[i][j] == 0 && ok == 1) ++cnt, cnt0++;
    if (ok == 0) nr++;
  }
  for (i = n; i >= 1; i--) {
    if (a[i][j] == 1)
      break;
    else
      nr1++;
  }
  cnt += cnt0 + nr - nr1;
}
int main() {
  int n, m, i, j, k, ok = 0, cnt = 0;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  n = citeste_rapid();
  m = citeste_rapid();
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) a[i][j] = citeste_rapid();
  for (i = 1; i <= n; i++) actori_orizontala(i, cnt, m);
  for (j = 1; j <= m; j++) actori_verticala(j, cnt, n);
  cout << cnt;
  return 0;
}
