#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, t = 0, min, d = 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];
  }
  vector<vector<int>> b(2, vector<int>(m, -1));
  vector<vector<int>> c(n, vector<int>(2, -1));
  for (int i = 0; i < m; i++) {
    min = -1;
    for (int j = 0; j < n; j++) {
      if (a[j][i] == 1 && min == -1) {
        b[0][i] = j;
        min = 0;
      }
      if (a[j][i] == 1) b[1][i] = j;
    }
  }
  for (int i = 0; i < n; i++) {
    min = -1;
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 1 && min == -1) {
        c[i][0] = j;
        min = 0;
      }
      if (a[i][j] == 1) c[i][1] = j;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 0) {
        if (b[0][j] < i && b[0][j] != -1) d++;
        if (b[1][j] > i && b[1][j] != -1) d++;
        if (c[i][0] < j && c[i][0] != -1) d++;
        if (c[i][1] > j && c[i][1] != -1) d++;
      }
    }
  }
  cout << d;
}
