#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long int n, m;
  cin >> n >> m;
  long long int mat[n][m];
  for (long long int i = 0; i < n; ++i) {
    for (long long int j = 0; j < m; ++j) {
      cin >> mat[i][j];
    }
  }
  long long int left[n][m], right[n][m], up[n][m], down[n][m];
  memset(left, 0, sizeof(left));
  memset(right, 0, sizeof(right));
  memset(up, 0, sizeof(up));
  memset(down, 0, sizeof(down));
  for (long long int i = 0; i < n; i++) {
    left[i][0] = mat[i][0];
    for (long long int j = 1; j < m; j++) {
      left[i][j] += (left[i][j - 1] + mat[i][j]);
    }
  }
  for (long long int i = 0; i < n; i++) {
    right[i][m - 1] = mat[i][m - 1];
    for (long long int j = m - 2; j >= 0; j--) {
      right[i][j] += (right[i][j + 1] + mat[i][j]);
    }
  }
  for (long long int i = 0; i < m; i++) {
    up[0][i] = mat[0][i];
    for (long long int j = 1; j < n; j++) {
      up[j][i] += (up[j - 1][i] + mat[j][i]);
    }
  }
  for (long long int i = 0; i < m; i++) {
    down[n - 1][i] = mat[n - 1][i];
    for (long long int j = n - 2; j >= 0; j--) {
      down[j][i] += (down[j + 1][i] + mat[j][i]);
    }
  }
  long long int cnt = 0;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      if (mat[i][j] == 0) {
        if (i - 1 >= 0 && up[i - 1][j]) cnt++;
        if (i + 1 < n && down[i + 1][j]) cnt++;
        if (j + 1 < m && right[i][j + 1]) cnt++;
        if (j - 1 >= 0 && left[i][j - 1]) cnt++;
      }
    }
  }
  cout << cnt << "\n";
  return 0;
}
