#include <bits/stdc++.h>
using namespace std;
int n, m, a;
int x[1010][1010];
long jumv = 0;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cin >> x[i][j];
  }
  for (int i = 1; i <= n; i++) {
    int j = 1;
    while (j <= m) {
      if (x[i][j] == 1) {
        while (j <= m) {
          if (x[i][j] == 0) jumv++;
          j++;
        }
      }
      j++;
    }
  }
  for (int i = 1; i <= n; i++) {
    int j = m;
    while (j >= 1) {
      if (x[i][j] == 1) {
        while (j >= 1) {
          if (x[i][j] == 0) jumv++;
          j--;
        }
      }
      j--;
    }
  }
  for (int j = 1; j <= m; j++) {
    int i = 1;
    while (i <= n) {
      if (x[i][j] == 1) {
        while (i <= n) {
          if (x[i][j] == 0) jumv++;
          i++;
        }
      }
      i++;
    }
  }
  for (int j = 1; j <= m; j++) {
    int i = n;
    while (i >= 1) {
      if (x[i][j] == 1) {
        while (i >= 1) {
          if (x[i][j] == 0) jumv++;
          i--;
        }
      }
      i--;
    }
  }
  cout << jumv << endl;
}
