#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  int ans = 0;
  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];
  }
  for (int i = 0; i < n; i++) {
    bool flag = false;
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == 1)
        flag = true;
      else {
        if (flag) ans++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    bool flag = false;
    for (int j = m - 1; j >= 0; j--) {
      if (arr[i][j] == 1)
        flag = true;
      else {
        if (flag) ans++;
      }
    }
  }
  for (int j = 0; j < m; j++) {
    bool flag = false;
    for (int i = n - 1; i >= 0; i--) {
      if (arr[i][j] == 1)
        flag = true;
      else {
        if (flag) ans++;
      }
    }
  }
  for (int j = 0; j < m; j++) {
    bool flag = false;
    for (int i = 0; i < n; i++) {
      if (arr[i][j] == 1)
        flag = true;
      else {
        if (flag) ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
