#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
vector<int> row[1010], col[1010];
int mapp[1010][1010];
int main() {
  cin.sync_with_stdio(false);
  int n, m;
  while (cin >> n >> m) {
    for (int i = 0; i < n; i++) {
      row[i].clear();
    }
    for (int i = 0; i < m; i++) {
      col[i].clear();
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> mapp[i][j];
        if (mapp[i][j] == 1) {
          row[i].push_back(j);
          col[j].push_back(i);
        }
      }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (mapp[i][j] == 0) {
          if (row[i].size()) {
            if (row[i][0] < j) {
              ans++;
            }
            if (row[i][row[i].size() - 1] > j) {
              ans++;
            }
          }
          if (col[j].size()) {
            if (col[j][0] < i) {
              ans++;
            }
            if (col[j][col[j].size() - 1] > i) {
              ans++;
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
