#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> mat(n, vector<int>(m, 0));
  vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
  for (int i = 1; i < n + 1; i++)
    for (int j = 1; j < m + 1; j++) {
      cin >> mat[i - 1][j - 1];
      dp[i][j] =
          dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + mat[i - 1][j - 1];
    }
  int cont = 0;
  for (int i = 1; i < n + 1; i++)
    for (int j = 1; j < m + 1; j++) {
      if (mat[i - 1][j - 1] == 0) {
        if (dp[i][j] - dp[i - 1][j] - dp[i][1 - 1] + dp[i - 1][1 - 1] >= 1) {
          cont++;
        }
        if (dp[i][j] - dp[1 - 1][j] - dp[i][j - 1] + dp[1 - 1][j - 1] >= 1) {
          cont++;
        }
        if (dp[i][m] - dp[i - 1][m] - dp[i][j - 1] + dp[i - 1][j - 1] >= 1) {
          cont++;
        }
        if (dp[n][j] - dp[i - 1][j] - dp[n][j - 1] + dp[i - 1][j - 1] >= 1) {
          cont++;
        }
      }
    }
  cout << cont;
  return 0;
}
