#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, j, ans = 0;
  cin >> n >> m;
  long long int a[n + 10][m + 10], row[n + 10][m + 10], col[m + 10][n + 10];
  memset(row, 0, sizeof(row));
  memset(col, 0, sizeof(col));
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) cin >> a[i][j];
  for (i = 0; i <= m + 1; i++) a[0][i] = a[n + 1][i] = 0;
  for (i = 0; i <= n + 1; i++) a[i][0] = a[i][m + 1] = 0;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) row[i][j] = row[i][j - 1] + a[i][j];
  for (j = 1; j <= m; j++)
    for (i = 1; i <= n; i++) col[j][i] = col[j][i - 1] + a[i][j];
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (a[i][j]) continue;
      if (row[i][m] - row[i][j]) ans++;
      if (row[i][j - 1]) ans++;
      if (col[j][n] - col[j][i]) ans++;
      if (col[j][i - 1]) ans++;
    }
  }
  cout << ans;
  return 0;
}
