#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pii = pair<T, T>;
long long a[1000][1000];
long long sumn[1000][1000];
long long summ[1000][1000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; cin >> a[i][j++])
      ;
  for (int i = 0; i < m; i++) sumn[0][i] = a[0][i];
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < m; j++) {
      sumn[i][j] = sumn[i - 1][j] + a[i][j];
    }
  }
  for (int i = 0; i < n; i++) summ[i][0] = a[i][0];
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < m; j++) {
      summ[i][j] = summ[i][j - 1] + a[i][j];
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 1) continue;
      if (sumn[n - 1][j] - sumn[i][j] > 0) cnt++;
      if (summ[i][m - 1] - summ[i][j] > 0) cnt++;
      if (sumn[i][j] > 0) cnt++;
      if (summ[i][j] > 0) cnt++;
    }
  }
  cout << cnt;
  return 0;
}
