#include <bits/stdc++.h>
using namespace std;
const int N = 2002;
int a[N][N] = {0}, b[N][N] = {0};
int c[N] = {0}, d[N] = {0}, e[N] = {0}, f[N] = {0};
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      b[i][j] = a[i][j];
      if (a[i][j] == 0) {
        if (c[i] == 1) ans++;
        if (d[j] == 1) ans++;
      } else {
        c[i] = 1, d[j] = 1;
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      if (b[i][j] == 0) {
        if (e[i] == 1) ans++;
        if (f[j] == 1) ans++;
      } else {
        e[i] = 1, f[j] = 1;
      }
    }
  }
  cout << ans << endl;
}
