#include <bits/stdc++.h>
using namespace std;
bool arr[1009][1009];
vector<pair<int, int> > vec;
int n, m, sum = 0;
void isDownGood(int i, int j) {
  for (i++; i < n; i++) {
    if (arr[i][j] == 1) return;
    sum++;
  }
}
void isUpGood(int i, int j) {
  for (i--; i >= 0; i--) {
    if (arr[i][j] == 1) return;
    sum++;
  }
}
void isRightGood(int i, int j) {
  for (j++; j < m; j++) {
    if (arr[i][j] == 1) return;
    sum++;
  }
}
void isLeftGood(int i, int j) {
  for (j--; j >= 0; j--) {
    if (arr[i][j] == 1) return;
    sum++;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &arr[i][j]);
      if (arr[i][j] == 1) vec.push_back(make_pair(i, j));
    }
  }
  for (int k = 0; k < vec.size(); k++) {
    int i = vec[k].first;
    int j = vec[k].second;
    isDownGood(i, j);
    isRightGood(i, j);
    isUpGood(i, j);
    isLeftGood(i, j);
  }
  printf("%d", sum);
  return 0;
}
