#include <bits/stdc++.h>
using namespace std;
long long n, m, stat, now;
int x[1005][1005];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) scanf("%d", &x[i][j]);
  }
  for (int i = 1; i <= n; i++) {
    stat = 0;
    for (int j = 1; j <= m; j++) {
      if (x[i][j] == 1) {
        stat = 1;
        continue;
      }
      if (stat) now++;
    }
  }
  for (int i = 1; i <= n; i++) {
    stat = 0;
    for (int j = m; j >= 1; j--) {
      if (x[i][j] == 1) {
        stat = 1;
        continue;
      }
      if (stat) now++;
    }
  }
  for (int j = 1; j <= m; j++) {
    stat = 0;
    for (int i = 1; i <= n; i++) {
      if (x[i][j] == 1) {
        stat = 1;
        continue;
      }
      if (stat) now++;
    }
  }
  for (int j = 1; j <= m; j++) {
    stat = 0;
    for (int i = n; i >= 1; i--) {
      if (x[i][j] == 1) {
        stat = 1;
        continue;
      }
      if (stat) now++;
    }
  }
  cout << now << endl;
  return 0;
}
