#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int> > UP, LEFT, DOWN, RIGHT;
  vector<vector<int> > matrix(n + 1, vector<int>(m + 1));
  UP = LEFT = RIGHT = DOWN = vector<vector<int> >(n + 2, vector<int>(m + 2, 0));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> matrix[i][j];
      RIGHT[i][j] = matrix[i][j] + RIGHT[i][j - 1];
      DOWN[i][j] = matrix[i][j] + DOWN[i - 1][j];
    }
  for (int i = n; i >= 1; i--)
    for (int j = m; j >= 1; j--) {
      UP[i][j] = matrix[i][j] + UP[i + 1][j];
      LEFT[i][j] = matrix[i][j] + LEFT[i][j + 1];
    }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (!matrix[i][j]) {
        if (LEFT[i][j + 1]) ans++;
        if (RIGHT[i][j - 1]) ans++;
        if (UP[i + 1][j]) ans++;
        if (DOWN[i - 1][j]) ans++;
      }
  cout << ans << endl;
  return 0;
}
