#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int s[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> s[i][j];
  int c = 0;
  for (int i = 0; i < n; i++) {
    bool seen = false;
    int last = 0;
    int c1 = 0;
    int proj = 0;
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 1) {
        seen = true;
        last = j;
      } else if (seen)
        c1++;
      if (!s[i][j]) proj++;
    }
    c += c1;
    if (seen) {
      c += proj - (m - last - 1);
    }
  }
  for (int j = 0; j < m; j++) {
    bool seen = false;
    int last = 0;
    int c1 = 0;
    int proj = 0;
    for (int i = 0; i < n; i++) {
      if (s[i][j] == 1) {
        seen = true;
        last = i;
      } else if (seen)
        c1++;
      if (!s[i][j]) proj++;
    }
    c += c1;
    if (seen) {
      c += proj - (n - last - 1);
    }
  }
  cout << c;
  return 0;
}
