#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18L + 5;
struct Data {
  long long int p;
  long long int h;
};
void ini() {}
bool comp(pair<long long int, long long int> &a,
          pair<long long int, long long int> &b) {
  return a.first > b.first;
}
long long int gcd(long long int a, long long int b) {
  while (a != 0) {
    long long int temp = a;
    a = b % a;
    b = temp;
  }
  return b;
}
void solve() {
  long long int n, m;
  cin >> n >> m;
  long long int a[n][m];
  map<long long int, set<long long int>> row, col;
  for (long long int i = (long long int)(0); i < (long long int)(n); i++) {
    for (long long int j = (long long int)(0); j < (long long int)(m); j++) {
      cin >> a[i][j];
      if (a[i][j] == 1) {
        row[i].insert(j);
        col[j].insert(i);
      }
    }
  }
  long long int ans = 0;
  for (long long int i = (long long int)(0); i < (long long int)(n); i++) {
    for (long long int j = (long long int)(0); j < (long long int)(m); j++) {
      if (a[i][j] == 0) {
        if (row[i].lower_bound(j) != row[i].end()) {
          ans++;
        }
        if (col[j].lower_bound(i) != col[j].end()) {
          ans++;
        }
        if (row[i].upper_bound(j) != row[i].begin()) {
          ans++;
        }
        if (col[j].upper_bound(i) != col[j].begin()) {
          ans++;
        }
      }
    }
  }
  cout << ans;
}
int main() {
  ini();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
