#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int m, n, st[1005][1005], cnt = 0, pref[1005][1005];
  cin >> n >> m;
  for (int i = 0; i < n + 1; i++) {
    pref[i][0] = 0;
  }
  for (int i = 0; i < m + 1; i++) {
    pref[0][i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> st[i][j];
      pref[i][j] = st[i][j];
      pref[i][j] += pref[i - 1][j];
      pref[i][j] += pref[i][j - 1];
      pref[i][j] -= pref[i - 1][j - 1];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (st[i][j] == 0) {
        if (pref[i][j] - pref[i - 1][j] > 0) cnt++;
        if (pref[i][j] - pref[i][j - 1] > 0) cnt++;
        if (pref[n][j] - pref[n][j - 1] - pref[i][j] + pref[i][j - 1] > 0)
          cnt++;
        if (pref[i][m] - pref[i - 1][m] - pref[i][j] + pref[i - 1][j] > 0)
          cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
