#include <bits/stdc++.h>
using namespace std;
int a[1001][1001];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &a[i][j]);
  int res = 0;
  for (int i = 0; i < n; i++) {
    int f = 0;
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 0)
        f++;
      else {
        res += f;
        f = 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    int f = 0;
    for (int j = m - 1; j >= 0; j--) {
      if (a[i][j] == 0)
        f++;
      else {
        res += f;
        f = 0;
      }
    }
  }
  for (int j = 0; j < m; j++) {
    int f = 0;
    for (int i = 0; i < n; i++) {
      if (a[i][j] == 0)
        f++;
      else {
        res += f;
        f = 0;
      }
    }
  }
  for (int j = 0; j < m; j++) {
    int f = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (a[i][j] == 0)
        f++;
      else {
        res += f;
        f = 0;
      }
    }
  }
  printf("%d\n", res);
  return 0;
}
