#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  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 c = 0;
  for (int i = 1; i <= n; i++) {
    int l = 0;
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == 1) l = 1;
      if (a[i][j] == 0) {
        if (l == 1) c++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    int l = 0;
    for (int j = m; j >= 1; j--) {
      if (a[i][j] == 1) l = 1;
      if (a[i][j] == 0) {
        if (l == 1) c++;
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    int l = 0;
    for (int j = 1; j <= n; j++) {
      if (a[j][i] == 1) l = 1;
      if (a[j][i] == 0) {
        if (l == 1) c++;
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    int l = 0;
    for (int j = n; j >= 1; j--) {
      if (a[j][i] == 1) l = 1;
      if (a[j][i] == 0) {
        if (l == 1) c++;
      }
    }
  }
  cout << c << endl;
}
