#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y;
  scanf("%d %d", &x, &y);
  int a[1005][1005];
  for (int i = 0; i < x; ++i) {
    for (int j = 0; j < y; ++j) {
      scanf("%d", &a[i][j]);
    }
  }
  int totZ = 0;
  int trueCount = 0;
  bool left = 0;
  bool right = 0;
  for (int i = 0; i < x; ++i) {
    left = 0;
    right = 0;
    totZ = 0;
    for (int j = 0; j < y; ++j) {
      if (a[i][j] == 0) {
        totZ++;
        if (y == j + 1) {
          if (left == true) {
            trueCount += totZ;
            totZ = 0;
          }
        }
      } else if (a[i][j] == 1) {
        left = right;
        right = true;
        if (left == false && right == true) {
          trueCount += totZ;
        } else if (left == true && right == true) {
          trueCount += totZ * 2;
        } else {
          trueCount += totZ;
        }
        totZ = 0;
        left = true;
      }
    }
  }
  totZ = 0;
  left = 0;
  right = 0;
  for (int j = 0; j < y; ++j) {
    left = 0;
    right = 0;
    totZ = 0;
    for (int i = 0; i < x; ++i) {
      if (a[i][j] == 0) {
        totZ++;
        if (x == i + 1) {
          if (left == true) {
            trueCount += totZ;
            totZ = 0;
          }
        }
      } else if (a[i][j] == 1) {
        left = right;
        right = true;
        if (left == false && right == true) {
          trueCount += totZ;
        } else if (left == true && right == true) {
          trueCount += totZ * 2;
        } else {
          trueCount += totZ;
        }
        totZ = 0;
        left = true;
      }
    }
  }
  printf("%d\n", trueCount);
  return 0;
}
