#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  long long i, j;
  long long arr[1002][1002];
  long long row[1002][2];
  long long col[1002][2];
  scanf("%lld%lld", &N, &M);
  for (long long int i = 1; i < N + 1; i++) {
    for (long long int j = 1; j < M + 1; j++) {
      scanf("%lld", &arr[i][j]);
    }
  }
  for (long long int i = 1; i < N + 1; i++) {
    long long mini = -1, maxi = -1;
    for (long long int j = 1; j < M + 1; j++) {
      if (arr[i][j] == 1 && maxi == -1 && mini == -1) {
        maxi = mini = j;
        continue;
      }
      if (arr[i][j]) {
        maxi = j;
      }
    }
    row[i][0] = mini;
    row[i][1] = maxi;
  }
  for (long long int j = 1; j < M + 1; j++) {
    long long mini = -1, maxi = -1;
    for (long long int i = 1; i < N + 1; i++) {
      if (arr[i][j] == 1 && mini == -1 && maxi == -1) {
        mini = maxi = i;
        continue;
      }
      if (arr[i][j]) {
        maxi = i;
      }
    }
    col[j][0] = mini;
    col[j][1] = maxi;
  }
  long long ans = 0;
  for (long long int i = 1; i < N + 1; i++) {
    if (row[i][0] == -1)
      continue;
    else {
      for (long long int j = 1; j < row[i][0]; j++) {
        if (arr[i][j] == 0) ans++;
      }
      for (long long int j = row[i][0]; j < row[i][1] + 1; j++) {
        if (arr[i][j] == 0) ans += 2;
      }
      for (long long int j = row[i][1] + 1; j < M + 1; j++) {
        if (arr[i][j] == 0) ans++;
      }
    }
  }
  for (long long int i = 1; i < M + 1; i++) {
    if (col[i][0] == -1)
      continue;
    else {
      for (long long int j = 1; j < col[i][0]; j++) {
        if (arr[j][i] == 0) ans++;
      }
      for (long long int j = col[i][0]; j < col[i][1] + 1; j++) {
        if (arr[j][i] == 0) ans += 2;
      }
      for (long long int j = col[i][1] + 1; j < N + 1; j++) {
        if (arr[j][i] == 0) ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
