#include <bits/stdc++.h>   using namespace std;   int main() {     long long int r, c, ans = 0;     cin >> r >> c;     vector<vector<long long int> > A(r + 2, vector<long long int>(c + 2));     for (long long int i = 1; i <= r; i++)       for (long long int j = 1; j <= c; j++) cin >> A[i][j];     vector<vector<long long int> > left(A), right(A), up(A), down(A);     for (long long int i = 1; i <= r; i++)       for (long long int j = 1; j <= c; j++) left[i][j] += left[i][j - 1];     for (long long int i = 1; i <= r; i++)       for (long long int j = c; j >= 1; j--) right[i][j] += right[i][j + 1];     for (long long int j = 1; j <= c; j++)       for (long long int i = 1; i <= r; i++) up[i][j] += up[i - 1][j];     for (long long int j = 1; j <= c; j++)       for (long long int i = r; i >= 1; i--) down[i][j] += down[i + 1][j];     for (long long int i = 1; i <= r; i++)       for (long long int j = 1; j <= c; j++)         if (A[i][j] == 0)           ans += (left[i][j - 1] != 0) + (right[i][j + 1] != 0) +                  (up[i - 1][j] != 0) + (down[i + 1][j] != 0);     cout << ans;   }   