#include <bits/stdc++.h>
using namespace std;
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename U>
string to_string(U u) {
  bool first = true;
  string res = "{";
  for (const auto& x : u) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename U, typename V>
string to_string(pair<U, V> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void print_debug() { cerr << endl; }
template <typename U, typename... V>
void print_debug(U u, V... v) {
  cerr << " " << to_string(u);
  print_debug(v...);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> grid(n, vector<int>(m));
  for (auto& row : grid) {
    for (auto& col : row) {
      cin >> col;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    bool ok = false;
    for (int k = 0; k < m; k++) {
      if (grid[i][k] == 1) {
        ok = true;
      }
      if (grid[i][k] == 0 && ok) {
        ans++;
      }
    }
    ok = false;
    for (int k = m - 1; k >= 0; k--) {
      if (grid[i][k] == 1) {
        ok = true;
      }
      if (grid[i][k] == 0 && ok) {
        ans++;
      }
    }
  }
  for (int j = 0; j < m; j++) {
    bool ok = false;
    for (int k = 0; k < n; k++) {
      if (grid[k][j] == 1) {
        ok = true;
      }
      if (grid[k][j] == 0 && ok) {
        ans++;
      }
    }
    ok = false;
    for (int k = n - 1; k >= 0; k--) {
      if (grid[k][j] == 1) {
        ok = true;
      }
      if (grid[k][j] == 0 && ok) {
        ans++;
      }
    }
  }
  cout << ans;
}
