#include <bits/stdc++.h>
using namespace std;
const int N = 1000;
int a[N + 19][N + 19], dp[N + 19][N + 19], n, m, ans = 0;
void readInput() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
}
void solve() {
  for (int i = 1; i <= n; i++) {
    int tmp = 0;
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == 1)
        tmp++;
      else if (a[i][j] == 0 and tmp > 0)
        ans++;
    }
  }
  for (int i = 1; i <= n; i++) {
    int tmp = 0;
    for (int j = m; j > 0; j--) {
      if (a[i][j] == 1)
        tmp++;
      else if (a[i][j] == 0 and tmp > 0)
        ans++;
    }
  }
  for (int j = 1; j <= m; j++) {
    int tmp = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i][j] == 1)
        tmp++;
      else if (a[i][j] == 0 and tmp > 0)
        ans++;
    }
  }
  for (int j = 1; j <= m; j++) {
    int tmp = 0;
    for (int i = n; i > 0; i--) {
      if (a[i][j] == 1)
        tmp++;
      else if (a[i][j] == 0 and tmp > 0)
        ans++;
    }
  }
}
void writeOutput() { cout << ans << endl; }
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  readInput();
  solve();
  writeOutput();
  return 0;
}
