#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
int main() {
  long long int m, n;
  cin >> n >> m;
  long long int a[n][m];
  for (long long int i = 0; i < n; ++i) {
    for (long long int j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }
  vector<pair<long long int, long long int>> row, col;
  for (long long int i = 0; i < n; ++i) {
    long long int minn = m + 1, maxx = -1;
    for (long long int j = 0; j < m; ++j) {
      if (a[i][j] == 1) {
        maxx = max(maxx, j);
        minn = min(minn, j);
      }
    }
    row.push_back(make_pair(minn, maxx));
  }
  for (long long int i = 0; i < m; ++i) {
    long long int minn = n + 1, maxx = -1;
    for (long long int j = 0; j < n; ++j) {
      if (a[j][i] == 1) {
        maxx = max(maxx, j);
        minn = min(minn, j);
      }
    }
    col.push_back(make_pair(minn, maxx));
  }
  long long int count = 0;
  for (long long int i = 0; i < n; ++i) {
    for (long long int j = 0; j < m; ++j) {
      if (a[i][j] == 0) {
        if (row[i].first < j) ++count;
        if (row[i].second > j) ++count;
        if (col[j].first < i) ++count;
        if (col[j].second > i) ++count;
      }
    }
  }
  cout << count;
}
