#include <bits/stdc++.h>
using namespace std;
int a[1001][1001] = {0}, b[1001][1001] = {0}, c[1001][1001] = {0};
int main() {
  long long n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      b[i][j] = a[i][j];
      c[i][j] = a[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < m; j++) b[i][j] += b[i][j - 1];
  }
  for (int i = 0; i < m; i++) {
    for (int j = 1; j < n; j++) c[j][i] += c[j - 1][i];
  }
  long long d = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] != 1) {
        if (b[i][j] > 0) d++;
        if (b[i][m - 1] - b[i][j] > 0) d++;
        if (c[i][j] > 0) d++;
        if (c[n - 1][j] - c[i][j] > 0) d++;
      }
    }
  }
  cout << d;
  return 0;
}
