#include <bits/stdc++.h>
using namespace std;
void solve() {
  int m, n, ans = 0;
  cin >> n >> m;
  int arr[n][m];
  int row_left[n];
  int row_right[n];
  int col_top[m];
  int col_down[m];
  memset(col_down, 0, sizeof(col_down));
  memset(row_right, 0, sizeof(row_right));
  memset(col_top, 0, sizeof(col_top));
  memset(row_left, 0, sizeof(row_left));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr[i][j]) {
        row_right[i]++;
        col_down[j]++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!arr[i][j]) {
        if (col_top[j] > 0) ans++;
        if (col_down[j] > 0) ans++;
        if (row_right[i] > 0) ans++;
        if (row_left[i] > 0) ans++;
      } else if (arr[i][j]) {
        row_left[i]++;
        col_top[j]++;
        if (row_right[i]) row_right[i]--;
        if (col_down[j]) col_down[j]--;
      }
    }
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
