#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  int m, n;
  cin >> n >> m;
  int a[n + 1][m + 1];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  int l[n + 1], r[n + 1], u[m + 1], d[m + 1];
  for (int i = 1; i <= n; i++) {
    l[i] = -1;
    r[i] = -1;
  }
  for (int i = 1; i <= m; i++) {
    u[i] = -1;
    d[i] = -1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == 1) {
        l[i] = j;
        break;
      }
    }
    for (int j = m; j >= 1; j--) {
      if (a[i][j] == 1) {
        r[i] = j;
        break;
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (a[j][i] == 1) {
        u[i] = j;
        break;
      }
    }
    for (int j = n; j >= 1; j--) {
      if (a[j][i] == 1) {
        d[i] = j;
        break;
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (l[i] != -1) {
      ans = ans + (l[i] - 1) + (m - r[i]);
    }
    for (int j = l[i] + 1; j < r[i]; j++) {
      if (a[i][j] == 0) {
        ans += 2;
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    if (u[i] != -1) {
      ans = ans + (u[i] - 1) + (n - d[i]);
    }
    for (int j = u[i] + 1; j < d[i]; j++) {
      if (a[j][i] == 0) {
        ans += 2;
      }
    }
  }
  cout << ans;
}
