#include <bits/stdc++.h>
using namespace std;
const int MAX = (long long)1e5;
const long long rem = (long long)1e9;
int n;
int m;
int t;
int a;
int b;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  vector<vector<int>> arr(n, vector<int>(m, 0));
  int uparNiche[n][m];
  int leftRight[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      uparNiche[i][j] = arr[i][j];
      if (i > 0) uparNiche[i][j] += uparNiche[i - 1][j];
      leftRight[i][j] = arr[i][j];
      if (j > 0) leftRight[i][j] += leftRight[i][j - 1];
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == 0) {
        if (i == 0) {
          if (j == 0) {
            if (leftRight[i][m - 1] > 0) {
              cnt++;
            }
            if (uparNiche[n - 1][j] > 0) {
              cnt++;
            }
          } else {
            if (uparNiche[n - 1][j] > 0) {
              cnt++;
            }
            if (leftRight[0][m - 1] - leftRight[0][j] > 0) {
              cnt++;
            }
            if (leftRight[0][j] > 0) {
              cnt++;
            }
          }
        } else if (j == 0) {
          if (uparNiche[i][j] > 0) {
            cnt++;
          }
          if (uparNiche[n - 1][j] - uparNiche[i][j] > 0) {
            cnt++;
          }
          if (leftRight[i][m - 1] > 0) {
            cnt++;
          }
        } else {
          if (uparNiche[i][j] > 0) {
            cnt++;
          }
          if (uparNiche[n - 1][j] - uparNiche[i][j] > 0) {
            cnt++;
          }
          if (leftRight[i][m - 1] - leftRight[i][j] > 0) {
            cnt++;
          }
          if (leftRight[i][j] > 0) {
            cnt++;
          }
        }
      }
    }
  }
  cout << cnt;
  return 0;
}
