#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int cell[1000][1000] = {0};
  cin >> n >> m;
  for (register int i = 0; i < n; ++i) {
    for (register int j = 0; j < m; ++j) {
      cin >> cell[i][j];
    }
  }
  int zeros = 0;
  int total_position = 0;
  bool there_was_an_actor = false;
  for (register int i = 0; i < n; ++i) {
    there_was_an_actor = false;
    for (register int j = 0; j < m; ++j) {
      if (cell[i][j]) {
        if (there_was_an_actor) {
          zeros--;
          total_position += zeros * 2;
          zeros = 0;
        } else {
          total_position += zeros;
          zeros = 0;
        }
        there_was_an_actor = true;
      }
      zeros++;
    }
    if (there_was_an_actor) {
      zeros--;
      total_position += zeros;
    }
    zeros = 0;
  }
  for (register int i = 0; i < m; ++i) {
    there_was_an_actor = false;
    for (register int j = 0; j < n; ++j) {
      if (cell[j][i]) {
        if (there_was_an_actor) {
          zeros--;
          total_position += zeros * 2;
          zeros = 0;
        } else {
          total_position += zeros;
          zeros = 0;
        }
        there_was_an_actor = true;
      }
      zeros++;
    }
    if (there_was_an_actor) {
      zeros--;
      total_position += zeros;
    }
    zeros = 0;
  }
  cout << total_position << endl;
  return 0;
}
