#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print(const vector<vector<T>>& v) {
  for (const auto& c : v) {
    for (const auto& r : c) {
      cout << r << ' ';
    }
    cout << endl;
  }
  cout << endl;
}
template <typename T>
void print(const vector<T>& v) {
  for (const auto& c : v) {
    cout << c << ' ';
  }
  cout << endl;
}
template <typename T>
T mulmod(T a, T b, T M) {
  T res = 0;
  while (a > 0) {
    if (a & 1) {
      res += b;
      if (res >= M) res -= M;
    }
    a >>= 1;
    b <<= 1;
    if (b >= M) b -= M;
  }
  return res;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> hsum(n, vector<int>(m));
  vector<vector<int>> vsum(n, vector<int>(m));
  vector<vector<int>> nums(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &nums[i][j]);
      hsum[i][j] = (j > 0 ? hsum[i][j - 1] + nums[i][j] : nums[i][j]);
      vsum[i][j] = (i > 0 ? vsum[i - 1][j] + nums[i][j] : nums[i][j]);
    }
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (nums[i][j] == 0) {
        if (hsum[i].back() - hsum[i][j] > 0) ++res;
        if (hsum[i][j] > 0) ++res;
        if (vsum.back()[j] - vsum[i][j] > 0) ++res;
        if (vsum[i][j] > 0) ++res;
      }
    }
  }
  cout << res << endl;
  return 0;
}
