#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  int grid[n + 1][m + 1];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> grid[i][j];
    }
  }
  int dp1[n + 1][m + 1];
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (j == 0) {
        dp1[i][j] = 0;
        continue;
      }
      dp1[i][j] = dp1[i][j - 1] + grid[i][j];
    }
  }
  int dp2[n + 1][m + 1];
  for (int j = 1; j <= m; j++) {
    for (int i = 0; i <= n; i++) {
      if (i == 0) {
        dp2[i][j] = 0;
        continue;
      }
      dp2[i][j] = dp2[i - 1][j] + grid[i][j];
    }
  }
  int ways = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (grid[i][j] == 0) {
        if (dp1[i][j - 1] > 0) {
          ways += 1;
        }
        if (dp1[i][m] > dp1[i][j]) {
          ways += 1;
        }
        if (dp2[i - 1][j] > 0) {
          ways += 1;
        }
        if (dp2[n][j] > dp2[i][j]) {
          ways += 1;
        }
      }
    }
  }
  cout << ways;
}
