#include <bits/stdc++.h>
using namespace std;
int grid[1004][1004];
int main() {
  int n, m;
  long long cnt = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) scanf("%d", &grid[i][j]);
  }
  for (int i = 0; i < n; i++) {
    bool ok = 0;
    for (int j = 0; j < m; j++) {
      if (grid[i][j] == 0 && ok) cnt++;
      if (grid[i][j] == 1) ok = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    bool ok = 0;
    for (int j = m - 1; j >= 0; j--) {
      if (grid[i][j] == 0 && ok) cnt++;
      if (grid[i][j] == 1) ok = 1;
    }
  }
  for (int j = 0; j < m; j++) {
    bool ok = 0;
    for (int i = 0; i < n; i++) {
      if (grid[i][j] == 0 && ok) cnt++;
      if (grid[i][j] == 1) ok = 1;
    }
  }
  for (int j = 0; j < m; j++) {
    bool ok = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (grid[i][j] == 0 && ok) cnt++;
      if (grid[i][j] == 1) ok = 1;
    }
  }
  printf("%d", cnt);
}
