#include <bits/stdc++.h>
using namespace std;
long long ans, tot;
map<long long, long long> mp;
long long n, a, b, c;
vector<long long> v;
long long dp[40001] = {};
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, i, j, cnt;
  cin >> n >> m;
  long long s[n][m];
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) cin >> s[i][j];
  for (i = 0; i < n; i++) {
    cnt = 0;
    for (j = 0; j < m; j++) {
      if (s[i][j] == 0)
        cnt++;
      else if (s[i][j] == 1) {
        ans += cnt;
        cnt = 0;
      }
    }
    cnt = 0;
    for (j = m - 1; j >= 0; j--) {
      if (s[i][j] == 0)
        cnt++;
      else if (s[i][j] == 1) {
        ans += cnt;
        cnt = 0;
      }
    }
  }
  for (i = 0; i < m; i++) {
    cnt = 0;
    for (j = 0; j < n; j++) {
      if (s[j][i] == 0)
        cnt++;
      else if (s[j][i] == 1) {
        ans += cnt;
        cnt = 0;
      }
    }
    cnt = 0;
    for (j = n - 1; j >= 0; j--) {
      if (s[j][i] == 0)
        cnt++;
      else if (s[j][i] == 1) {
        ans += cnt;
        cnt = 0;
      }
    }
  }
  cout << ans;
}
