#include <bits/stdc++.h>
using namespace std;
int c[1001][1001];
int cnt[1001][1001];
int cnt1[1001][1001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cnt[i][j] = cnt[i][j - 1];
      cin >> c[i][j];
      if (c[i][j]) cnt[i][j]++;
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      cnt1[j][i] = cnt1[j - 1][i];
      if (c[j][i]) cnt1[j][i]++;
    }
  }
  int ans1 = 0, ans2 = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (!c[i][j]) {
        if (cnt[i][j]) ans1++;
        if (cnt[i][m] != cnt[i][j] and j != m) ans1++;
        if (cnt1[i][j]) ans2++;
        if (cnt1[i][j] != cnt1[n][j] and i != n) ans2++;
      }
    }
  }
  cout << ans1 + ans2 << "\n";
  return 0;
}
