#include <bits/stdc++.h>
using namespace std;
const int sz = 1e3 + 1;
int ar[sz][sz];
bool dir[sz][sz];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &ar[i][j]);
    }
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < m; j++) {
      if (ar[i][j - 1] == 1) {
        dir[i][j] = 1;
      } else {
        dir[i][j] = dir[i][j - 1];
      }
      if (dir[i][j] && ar[i][j] == 0) {
        res++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      dir[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = m - 2; j >= 0; j--) {
      if (ar[i][j + 1] == 1) {
        dir[i][j] = 1;
      } else {
        dir[i][j] = dir[i][j + 1];
      }
      if (dir[i][j] && ar[i][j] == 0) {
        res++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      dir[i][j] = 0;
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (ar[i - 1][j] == 1) {
        dir[i][j] = 1;
      } else {
        dir[i][j] = dir[i - 1][j];
      }
      if (dir[i][j] && ar[i][j] == 0) {
        res++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      dir[i][j] = 0;
    }
  }
  for (int i = n - 2; i >= 0; i--) {
    for (int j = 0; j < m; j++) {
      if (ar[i + 1][j] == 1) {
        dir[i][j] = 1;
      } else {
        dir[i][j] = dir[i + 1][j];
      }
      if (dir[i][j] && ar[i][j] == 0) {
        res++;
      }
    }
  }
  printf("%d", res);
  return 0;
}
