#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, grid[1005][1005], cnt = 0, K[1005][1005];
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &grid[i][j]);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (grid[i][j]) {
        for (int k = i - 1; k > 0; k--) {
          if (grid[k][j] == 0)
            K[k][j]++;
          else
            break;
        }
        for (int k = i + 1; k <= n; k++) {
          if (grid[k][j] == 0)
            K[k][j]++;
          else
            break;
        }
        for (int k = j - 1; k > 0; k--) {
          if (grid[i][k] == 0)
            K[i][k]++;
          else
            break;
        }
        for (int k = j + 1; k <= m; k++) {
          if (grid[i][k] == 0)
            K[i][k]++;
          else
            break;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cnt += K[i][j];
  printf("%d", cnt);
}
