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