#include <bits/stdc++.h>
using namespace std;
bool check_down(int i, int j, int n, vector<vector<int>> &dpc,
                vector<vector<int>> &arr) {
  if (i == n - 1) return false;
  return dpc[i][j] - dpc[n - 1][j] != 0;
}
bool check_up(int i, int j, int n, vector<vector<int>> &dpc,
              vector<vector<int>> &arr) {
  if (i == 0) return false;
  return arr[i][j] - dpc[i][j] != 0;
}
bool check_left(int i, int j, int m, vector<vector<int>> &dpr,
                vector<vector<int>> &arr) {
  if (j == 0) return false;
  return arr[i][j] - dpr[i][j] != 0;
}
bool check_right(int i, int j, int m, vector<vector<int>> &dpr,
                 vector<vector<int>> &arr) {
  if (j == m - 1) return false;
  return dpr[i][j] - dpr[i][m - 1] != 0;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> arr(n, vector<int>(m, 0));
  vector<vector<int>> dpc(n, vector<int>(m, 0));
  vector<vector<int>> dpr(n, vector<int>(m, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
      if (i == 0)
        dpc[i][j] = arr[i][j];
      else
        dpc[i][j] = arr[i][j] + dpc[i - 1][j];
      if (j == 0)
        dpr[i][j] = arr[i][j];
      else
        dpr[i][j] = arr[i][j] + dpr[i][j - 1];
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int cur_val = 0;
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == 0) {
        cur_val += check_down(i, j, n, dpc, arr) + check_up(i, j, n, dpc, arr) +
                   check_left(i, j, m, dpr, arr) +
                   check_right(i, j, m, dpr, arr);
      }
    }
    sum += cur_val;
  }
  cout << sum;
  return 0;
}
