#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
void print(int* a, int n) {
  int i;
  for (i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
long long int arrMax(long long int* a, long long int n) {
  long long int i, max = a[0];
  for (i = 1; i < n; i++) {
    if (a[i] > max) max = a[i];
  }
  return max;
}
void print2d(int a[][100], int m, int n) {
  int i, j;
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      cout << setw(2) << a[i][j];
    }
    cout << endl;
  }
}
void fio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int main() {
  fio();
  int n, m;
  cin >> n >> m;
  int a[n][m][5];
  memset(a, 0, sizeof(a));
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> a[i][j][0];
    }
  }
  for (i = 0; i < n; i++) {
    a[i][0][4] = 0;
  }
  for (i = 0; i < n; i++) {
    for (j = 1; j < m; j++) {
      a[i][j][4] = a[i][j - 1][4];
      if (a[i][j - 1][0] == 1) a[i][j][4] = 1;
    }
  }
  for (i = 0; i < n; i++) {
    a[i][m - 1][2] = 0;
  }
  for (i = 0; i < n; i++) {
    for (j = m - 2; j >= 0; j--) {
      a[i][j][2] = a[i][j + 1][2];
      if (a[i][j + 1][0] == 1) a[i][j][2] = 1;
    }
  }
  for (i = 0; i < m; i++) {
    a[0][i][1] = 0;
  }
  for (i = 1; i < n; i++) {
    for (j = 0; j < m; j++) {
      a[i][j][1] = a[i - 1][j][1];
      if (a[i - 1][j][0] == 1) a[i][j][1] = 1;
    }
  }
  for (i = 0; i < m; i++) {
    a[n - 1][i][3] = 0;
  }
  for (i = n - 2; i >= 0; i--) {
    for (j = 0; j < m; j++) {
      a[i][j][3] = a[i + 1][j][3];
      if (a[i + 1][j][0] == 1) a[i][j][3] = 1;
    }
  }
  int k;
  long long sum = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (a[i][j][0] == 1) continue;
      for (k = 1; k < 5; k++) {
        sum += a[i][j][k];
      }
    }
  }
  cout << sum;
}
