#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, f = 0, ans = 0;
  cin >> n >> m;
  int a[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cin >> a[i][j];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 1) {
        f = 1;
      } else if (a[i][j] == 0 && f) {
        ans++;
      }
    }
    f = 0;
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (a[j][i] == 1) {
        f = 1;
      } else if (a[j][i] == 0 && f) {
        ans++;
      }
    }
    f = 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = m - 1; j >= 0; j--) {
      if (a[i][j] == 1) {
        f = 1;
      } else if (a[i][j] == 0 && f) {
        ans++;
      }
    }
    f = 0;
  }
  for (int i = 0; i < m; i++) {
    for (int j = n - 1; j >= 0; j--) {
      if (a[j][i] == 1) {
        f = 1;
      } else if (a[j][i] == 0 && f) {
        ans++;
      }
    }
    f = 0;
  }
  cout << ans;
  return 0;
}
