#include <bits/stdc++.h>
using namespace std;
const long long inf = 2e18;
const long double ep = 0.0000001;
const long double pi = acos(-1.0);
const long long hell = 1000000007;
bool sortbysec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.second < b.second);
}
bool isprime(long long a) {
  for (long long i = 2; i <= sqrt(a); i++) {
    if (a % i == 0) return false;
  }
  return true;
}
long long mulp(long long a, long long b) {
  return ((a % hell) * (b % hell)) % hell;
}
void SKJ() {
  long long n, m, cnt = 0;
  cin >> n >> m;
  long long r[n + 1][m + 1], c[n + 1][m + 1], a[n + 1][m + 1];
  memset(c, 0, sizeof(c));
  memset(r, 0, sizeof(r));
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      cin >> a[i][j];
      r[i][j] = r[i][j - 1];
      c[i][j] = c[i - 1][j];
      if (a[i][j] == 1) {
        r[i][j] += 1;
        c[i][j] += 1;
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      if (a[i][j] == 0) {
        if (r[i][j] > 0) cnt++;
        if (c[i][j] > 0) cnt++;
        if (r[i][m] > r[i][j]) cnt++;
        if (c[n][j] > c[i][j]) cnt++;
      }
    }
  }
  cout << cnt;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  t = 1;
  while (t--) {
    SKJ();
    cout << '\n';
  }
}
