#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n;
  cin >> m >> n;
  bool a[m][n];
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  long long int ans = 0;
  bool r[m][n], L[m][n], u[m][n], w[m][n];
  for (int i = 0; i < m; i++) {
    int t = 0;
    for (int j = 0; j < n; j++) {
      if (t == 1 && a[i][j] == 0) {
        ans++;
      }
      if (a[i][j] == 1) {
        t = 1;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    int t = 0;
    for (int j = n - 1; j >= 0; j--) {
      if (t == 1 && a[i][j] == 0) {
        ans++;
      }
      if (a[i][j] == 1) {
        t = 1;
      }
    }
  }
  for (int j = 0; j < n; j++) {
    int t = 0;
    for (int i = 0; i < m; i++) {
      if (t == 1 && a[i][j] == 0) {
        ans++;
      }
      if (a[i][j] == 1) {
        t = 1;
      }
    }
  }
  for (int j = 0; j < n; j++) {
    int t = 0;
    for (int i = m - 1; i >= 0; i--) {
      if (t == 1 && a[i][j] == 0) {
        ans++;
      }
      if (a[i][j] == 1) {
        t = 1;
      }
    }
  }
  cout << ans;
}
