#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int m;
  cin >> n >> m;
  vector<vector<bool>> arr(n, vector<bool>(m, 0));
  long long int answ = 0;
  vector<int> hor(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int temp;
      cin >> temp;
      if (!temp) {
        hor[i]++;
      }
      arr[i][j] = (bool)temp;
    }
  }
  vector<int> vert(m, 0);
  for (int j = 0; j < m; j++) {
    for (int i = 0; i < n; i++) {
      if (!arr[i][j]) {
        vert[j]++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    int past = 0;
    for (int j = 0; j < m; j++) {
      if (arr[i][j]) {
        answ += hor[i] - past;
        break;
      } else {
        past++;
      }
    }
    past = 0;
    for (int j = m - 1; j >= 0; j--) {
      if (arr[i][j]) {
        answ += hor[i] - past;
        break;
      } else {
        past++;
      }
    }
  }
  for (int j = 0; j < m; j++) {
    int past = 0;
    for (int i = 0; i < n; i++) {
      if (arr[i][j]) {
        answ += vert[j] - past;
        break;
      } else {
        past++;
      }
    }
    past = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (arr[i][j]) {
        answ += vert[j] - past;
        break;
      } else {
        past++;
      }
    }
  }
  cout << answ << endl;
  return 0;
}
