#include <bits/stdc++.h>
int a[1005][1005];
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    int s = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (a[i][j] == 1) {
          for (int k = i - 1; k >= 1; k--) {
            if (a[k][j] == 0)
              s++;
            else
              break;
          }
          for (int k = i + 1; k <= n; k++) {
            if (a[k][j] == 0)
              s++;
            else
              break;
          }
          for (int k = j - 1; k >= 1; k--) {
            if (a[i][k] == 0)
              s++;
            else
              break;
          }
          for (int k = j + 1; k <= m; k++) {
            if (a[i][k] == 0)
              s++;
            else
              break;
          }
        }
      }
    }
    printf("%d\n", s);
  }
}
