#include <bits/stdc++.h>
int a[1005][1005];
int main() {
  int m, n, i, k, b[1005], c[1005], m1[1005], m2[1005];
  long long sum;
  while (~scanf("%d%d", &m, &n)) {
    memset(b, 0, sizeof(b));
    memset(c, 0, sizeof(c));
    memset(m1, 0, sizeof(m1));
    memset(m2, 0, sizeof(m2));
    sum = 0;
    for (i = 0; i < m; i++) {
      for (k = 0; k < n; k++) {
        scanf("%d", &a[i][k]);
        if (a[i][k] == 0) {
          b[i] += 1;
          c[k] += 1;
        } else if (a[i][k] == 1) {
          m1[i] += 1;
          m2[k] += 1;
          if (m1[i] == 1) {
            sum += b[i];
            b[i] = 0;
          } else {
            sum += (b[i] * 2);
            b[i] = 0;
          }
          if (m2[k] == 1) {
            sum += c[k];
            c[k] = 0;
          } else {
            sum += (c[k] * 2);
            c[k] = 0;
          }
        }
        if (i == m - 1 && m2[k] > 0) sum += c[k];
      }
      if (m1[i] > 0) sum += b[i];
    }
    printf("%lld\n", sum);
  }
}
