#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > g(n, vector<int>(m));
  vector<vector<int> > up(n, vector<int>(m));
  vector<vector<int> > down(n, vector<int>(m));
  vector<vector<int> > left(n, vector<int>(m));
  vector<vector<int> > right(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> g[i][j];
      if (i == 0) {
        down[i][j] = g[i][j];
      } else {
        down[i][j] = down[i - 1][j] + g[i][j];
      }
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < m; j++) {
      if (i == n - 1) {
        up[i][j] = g[i][j];
      } else {
        up[i][j] = g[i][j] + up[i + 1][j];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (j == 0) {
        left[i][j] = g[i][j];
      } else {
        left[i][j] = left[i][j - 1] + g[i][j];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = m - 1; j >= 0; j--) {
      if (j == m - 1) {
        right[i][j] = g[i][j];
      } else {
        right[i][j] = right[i][j + 1] + g[i][j];
      }
    }
  }
  unsigned long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (g[i][j]) {
        continue;
      }
      if (down[i][j]) {
        ans++;
      }
      if (up[i][j]) {
        ans++;
      }
      if (left[i][j]) {
        ans++;
      }
      if (right[i][j]) {
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
