#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, lastp;
  vector<int> down;
  vector<int> left;
  vector<int> up;
  vector<int> right;
  bool pos;
  bool a[1000][1000];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    left.push_back(1001);
    lastp = 0;
    for (int j = 0; j < m; j++) {
      cin >> pos;
      a[i][j] = pos;
      if (left[i] == 1001 && pos) left[i] = j + 1;
      if (pos) lastp = j;
    }
    right.push_back(lastp - 1);
  }
  for (int i = 0; i < m; i++) {
    up.push_back(1001);
    lastp = 0;
    for (int j = 0; j < n; j++) {
      pos = a[j][i];
      if (up[i] == 1001 && pos) up[i] = j + 1;
      if (pos) lastp = j;
    }
    down.push_back(lastp - 1);
  }
  int q = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 0) {
        q += (j >= left[i]);
        q += (j <= right[i]);
        q += (i >= up[j]);
        q += (i <= down[j]);
      }
    }
  }
  cout << q;
}
