#include <bits/stdc++.h>
const int N = 1e5 + 5;
const long double pi = 3.141592653;
const long long MOD = 1e9 + 7;
const long long mod = 998244353;
const long long INF = 9223372036854775807LL;
using namespace std;
int dx[9] = {1, -1, 0, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 0, 1, -1, 1, -1, 1, -1, 0};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  while (T--) {
    int n, m, i, j, ans = 0, a[1005][1005];
    cin >> n >> m;
    vector<pair<int, int> > row(n + 1, {m + 1, -1});
    vector<pair<int, int> > col(m + 1, {n + 1, -1});
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) cin >> a[i][j];
    }
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        if (a[i][j] == 1) {
          row[i].first = min(row[i].first, j);
          row[i].second = max(row[i].second, j);
        }
      }
    }
    for (j = 1; j <= m; j++) {
      for (i = 1; i <= n; i++) {
        if (a[i][j] == 1) {
          col[j].first = min(col[j].first, i);
          col[j].second = max(col[j].second, i);
        }
      }
    }
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        if (a[i][j] == 0) {
          if (row[i].second == -1) {
          } else {
            if (j > row[i].second)
              ans++;
            else if (j < row[i].first)
              ans++;
            else
              ans = ans + 2;
          }
          if (col[j].second == -1) {
          } else {
            if (i > col[j].second)
              ans++;
            else if (i < col[j].first)
              ans++;
            else
              ans = ans + 2;
          }
        }
      }
    }
    cout << ans;
  }
  return 0;
}
