#include <bits/stdc++.h>
int xibo[1001][1001];
int main() {
  int n, m, ans = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &xibo[i][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (xibo[i][j]) {
        for (int a = i - 1; a >= 1 && xibo[a][j] == 0; a--, ans++)
          ;
        for (int a = i + 1; a <= n && xibo[a][j] == 0; a++, ans++)
          ;
        for (int a = j - 1; a >= 1 && xibo[i][a] == 0; a--, ans++)
          ;
        for (int a = j + 1; a <= m && xibo[i][a] == 0; a++, ans++)
          ;
      }
  printf("%d", ans);
}
