#include <bits/stdc++.h>
using namespace std;
const long long L9 = 1000000000;
const long long L8 = 100000000;
const long long L7 = 10000000;
const long long L6 = 1000000;
const long long L5 = 100000;
const long long L4 = 10000;
const long long L3 = 1000;
const long long L2 = 100;
const long long L1 = 10;
const double PI = acos(-1);
const long long LONG_INF = (1ll << 63) - 1;
const unsigned long long ULONG_INF = 0 - 1;
const int INT_INF = (1ll << 31) - 1;
int x, y;
bool a[1000][1000];
bool u[1000][1000], l[1000][1000], r[1000][1000], d[1000][1000];
int main(int argc, char** argv) {
  cin >> x >> y;
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      cin >> a[i][j];
      if (!a[i][j]) {
        if (i - 1 >= 0) u[i][j] = u[i - 1][j] | a[i - 1][j];
        if (j - 1 >= 0) l[i][j] = l[i][j - 1] | a[i][j - 1];
      }
    }
  }
  for (int i = x - 1; i >= 0; i--) {
    for (int j = y - 1; j >= 0; j--) {
      if (!a[i][j]) {
        if (i + 1 < x) d[i][j] = d[i + 1][j] | a[i + 1][j];
        if (j + 1 < y) r[i][j] = r[i][j + 1] | a[i][j + 1];
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      if (!a[i][j]) {
        ans += u[i][j];
        ans += d[i][j];
        ans += l[i][j];
        ans += r[i][j];
      }
    }
  }
  cout << ans;
}
