#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n;
  cin >> n >> m;
  vector<vector<int> > v(n, vector<int>(m));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> v[i][j];
    }
  vector<vector<int> > rows(n, vector<int>(m)), cols(n, vector<int>(m));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      rows[i][j] = (j == 0 ? v[i][j] : rows[i][j - 1] + v[i][j]);
      cols[i][j] = (i == 0 ? v[i][j] : cols[i - 1][j] + v[i][j]);
    }
  int k = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (v[i][j] == 1) continue;
      if (rows[i][m - 1] - rows[i][j] > 0) k++;
      if (cols[n - 1][j] - cols[i][j] > 0) k++;
      if (j > 0 && rows[i][j - 1] > 0) k++;
      if (i > 0 && cols[i - 1][j] > 0) k++;
    }
  cout << k;
  return 0;
}
