#include <bits/stdc++.h>
using namespace std;
int c[1000], r[1000], c1[1000], r1[1000], sum[1000][1000], a[1000][1000];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 1) {
        r[i] = 1;
        c[j] = 1;
      } else {
        if (r[i] == 1) sum[i][j]++;
        if (c[j]) sum[i][j]++;
      }
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = m - 1; j >= 0; j--) {
      if (a[i][j] == 1) {
        r1[i] = 1;
        c1[j] = 1;
      } else {
        if (r1[i]) sum[i][j]++;
        if (c1[j]) sum[i][j]++;
      }
    }
  }
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 0) cnt += sum[i][j];
    }
  }
  cout << cnt << endl;
}
