#include <bits/stdc++.h>
using namespace std;
int i, n, ans, a[1111][1111], m, dp[1111][1111], pd[1111][1111], qp[1111][1111],
    pq[1111][1111];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] || dp[i - 1][j]) dp[i][j] = 1;
      if (a[i][j] || pd[i][j - 1]) pd[i][j] = 1;
    }
  for (int i = n; i > 0; i--)
    for (int j = m; j > 0; j--) {
      if (a[i][j] || pq[i + 1][j]) pq[i][j] = 1;
      if (a[i][j] || qp[i][j + 1]) qp[i][j] = 1;
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (!a[i][j]) {
        ans += dp[i - 1][j] + pq[i + 1][j] + pd[i][j - 1] + qp[i][j + 1];
      }
  cout << ans;
}
