#include <bits/stdc++.h>
using namespace std;
long long arr[1010][1010];
long long l[1010];
long long r[1010];
long long u[1010];
long long d[1010];
int main() {
  int n, m, i, j;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cin >> arr[i][j];
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (arr[i][j] == 1) {
        l[i] = j;
        break;
      }
    }
    for (j = m; j >= 1; j--) {
      if (arr[i][j] == 1) {
        r[i] = j;
        break;
      }
    }
  }
  for (i = 1; i <= m; i++) {
    for (j = 1; j <= n; j++) {
      if (arr[j][i] == 1) {
        u[i] = j;
        break;
      }
    }
    for (j = n; j >= 1; j--) {
      if (arr[j][i] == 1) {
        d[i] = j;
        break;
      }
    }
  }
  int cnt = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (arr[i][j] == 0) {
        if (l[i] != 0 && j > l[i]) cnt++;
        if (r[i] != 0 && j < r[i]) cnt++;
        if (d[j] != 0 && i < d[j]) cnt++;
        if (u[j] != 0 && i > u[j]) cnt++;
      }
    }
  }
  cout << cnt << endl;
}
