#include <bits/stdc++.h>
using namespace std;
int row, col;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> row >> col;
  vector<pair<int, int>> hor(row, {INT_MAX, INT_MIN});
  vector<pair<int, int>> ver(col, {INT_MAX, INT_MIN});
  vector<list<int>> good_pos(row);
  for (int i = 0; i < row; i++)
    for (int j = 0; j < col; j++) {
      int a;
      cin >> a;
      if (a) {
        hor[i].first = min(hor[i].first, j);
        hor[i].second = max(hor[i].second, j);
        ver[j].first = min(ver[j].first, i);
        ver[j].second = max(ver[j].second, i);
      } else
        good_pos[i].push_back(j);
    }
  int answer = 0;
  for (int i = 0; i < row; i++) {
    for (auto cur_col : good_pos[i]) {
      if (cur_col > hor[i].first) {
        answer++;
      }
      if (cur_col < hor[i].second) {
        answer++;
      }
      if (i > ver[cur_col].first) {
        answer++;
      }
      if (i < ver[cur_col].second) {
        answer++;
      }
    }
  }
  cout << answer;
  return 0;
}
