#include <bits/stdc++.h>
using namespace std;
int row[1005][2];
int coloumn[1005][3];
int main() {
  int m, n;
  cin >> n >> m;
  short x[1005][1005];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> x[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (x[i][j] == 1) {
        row[i][0] = j + 1;
        break;
      }
    }
    for (int j = m - 1; j >= 0; j--) {
      if (x[i][j] == 1) {
        row[i][1] = j + 1;
        break;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (x[j][i] == 1) {
        coloumn[i][0] = j + 1;
        break;
      }
    }
    for (int j = n - 1; j >= 0; j--) {
      if (x[j][i] == 1) {
        coloumn[i][1] = j + 1;
        break;
      }
    }
  }
  int num = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (x[i][j] == 0) {
        if (j > row[i][0] - 1 && row[i][0] != 0) num++;
        if (j < row[i][1] - 1 && row[i][1] != 0) num++;
        if (i > coloumn[j][0] - 1 && coloumn[j][0] != 0) num++;
        if (i < coloumn[j][1] - 1 && coloumn[j][1] != 0) num++;
      }
    }
  }
  cout << num;
}
