#include <bits/stdc++.h>
int main() {
  int n1, n2, n3 = 0;
  std::cin >> n1 >> n2;
  std::vector<std::vector<int>> v1(n1, std::vector<int>(n2));
  for (int i = 0; i < n1; i++)
    for (int j = 0; j < n2; j++) std::cin >> v1[i][j];
  auto f1 = [&](int y, int x) {
    int i = y, j = x - 1;
    while (j >= 0 && !v1[i][j]) n3++, j--;
    i = y, j = x + 1;
    while (j < n2 && !v1[i][j]) n3++, j++;
    i = y - 1, j = x;
    while (i >= 0 && !v1[i][j]) n3++, i--;
    i = y + 1, j = x;
    while (i < n1 && !v1[i][j]) n3++, i++;
  };
  for (int i = 0; i < n1; i++)
    for (int j = 0; j < n2; j++)
      if (v1[i][j]) f1(i, j);
  std::cout << n3;
}
