#include <bits/stdc++.h>
using namespace std;
int i, j;
const int SZ = 1e3 + 10;
int c_x[SZ], c_y[SZ], f_x[SZ], l_x[SZ], f_y[SZ], l_y[SZ];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  fill(begin(f_x), end(f_x), -1);
  fill(begin(f_y), end(f_y), -1);
  int w, h, buf;
  long long ans = 0;
  cin >> h >> w;
  for (i = (0); i < (h); i++)
    for (j = (0); j < (w); j++) {
      cin >> buf;
      if (buf) {
        c_y[i]++, c_x[j]++;
        if (f_y[i] == -1) f_y[i] = j;
        if (f_x[j] == -1) f_x[j] = i;
        l_y[i] = j, l_x[j] = i;
      }
    }
  for (i = (0); i < (h); i++)
    if (c_y[i]) ans += l_y[i] + 1 + w - f_y[i] - c_y[i] * 2;
  for (j = (0); j < (w); j++)
    if (c_x[j]) ans += l_x[j] + 1 + h - f_x[j] - c_x[j] * 2;
  cout << ans << '\n';
}
