#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  return a ? gcd(b % a, a) : b;
}
template <typename T>
T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
string int_to_str_easy(long long n) {
  return n ? "" : int_to_str_easy(n / 10) + (char)('0' + n % 10);
}
template <typename T>
T sum(vector<T> v) {
  T ans = 0;
  for (T i : v) ans += i;
  return ans;
}
template <typename T>
bool is_prime_sqrt(T n) {
  if (n == 1) return false;
  T k = trunc(sqrt(n));
  for (T i = 2; i <= k; i++)
    if (n % i == 0) return false;
  return true;
}
bool is_down(char x) { return ('a' <= x && x <= 'z'); }
bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
bool is_digit(char x) { return ('0' <= x && x <= '9'); }
string follow(string s) {
  for (int i = 0; i < s.length(); i++)
    if (is_upper(s[i])) s[i] += 'a' - 'A';
  return s;
}
const long double pi = 3.141592653589793238462643383279;
const long double log23 = 1.58496250072115618145373894394781;
const long double eps = 1e-8;
const long double zero = 0;
const long long INF = 1e18;
const int COUT = 30;
const int prost = 239;
const long long prost64 = 239;
const int two = 2;
const long long sr = 31;
const long long MOD = 1000000007;
const int BIG = 1e9;
const int alf = 26;
const int MAX_N = 2 * 1e5 + 1;
const int MAX_M = 1001;
const int km = (1 << 18) - 1;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int bit_max = 32;
const string str_alf = "abcdefghijklmnopqrstuvwxyz";
const string str_alf_big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
void solve() { return; }
int n, m, a[MAX_M][MAX_M];
bool dp[4][MAX_M][MAX_M];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &a[i][j]);
  for (int i = 0; i < n; i++) {
    dp[0][i][0] = false;
    for (int j = 1; j < m; j++) {
      if (dp[0][i][j - 1]) {
        dp[0][i][j] = true;
        continue;
      }
      dp[0][i][j] = (a[i][j - 1] == 1);
    }
    dp[1][i][m - 1] = false;
    for (int j = m - 2; j >= 0; j--) {
      if (dp[1][i][j + 1]) {
        dp[1][i][j] = true;
        continue;
      }
      dp[1][i][j] = (a[i][j + 1] == 1);
    }
  }
  for (int i = 0; i < m; i++) {
    dp[2][0][i] = false;
    for (int j = 1; j < n; j++) {
      if (dp[2][j - 1][i]) {
        dp[2][j][i] = true;
        continue;
      }
      dp[2][j][i] = (a[j - 1][i] == 1);
    }
    dp[3][n - 1][i] = false;
    for (int j = n - 2; j >= 0; j--) {
      if (dp[3][j + 1][i]) {
        dp[3][j][i] = true;
        continue;
      }
      dp[3][j][i] = (a[j + 1][i] == 1);
    }
  }
  int ans = 0;
  for (int h = 0; h < 4; h++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (a[i][j] == 0 && dp[h][i][j]) ans++;
  cout << ans;
  return 0;
}

### Prompt

Construct a cpp code solution to the problem outlined:

Theater stage is a rectangular field of size n × m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not.

You are to place a spotlight on the stage in some good position. The spotlight will project light in one of the four directions (if you look at the stage from above) — left, right, up or down. Thus, the spotlight's position is a cell it is placed to and a direction it shines.

A position is good if two conditions hold: 

  * there is no actor in the cell the spotlight is placed to; 
  * there is at least one actor in the direction the spotlight projects. 



Count the number of good positions for placing the spotlight. Two positions of spotlight are considered to be different if the location cells or projection direction differ.

Input

The first line contains two positive integers n and m (1 ≤ n, m ≤ 1000) — the number of rows and the number of columns in the plan.

The next n lines contain m integers, 0 or 1 each — the description of the plan. Integer 1, means there will be an actor in the corresponding cell, while 0 means the cell will remain empty. It is guaranteed that there is at least one actor in the plan.

Output

Print one integer — the number of good positions for placing the spotlight.

Examples

Input

2 4
0 1 0 0
1 0 1 0


Output

9


Input

4 4
0 0 0 0
1 0 0 1
0 1 1 0
0 1 0 0


Output

20

Note

In the first example the following positions are good:

  1. the (1, 1) cell and right direction; 
  2. the (1, 1) cell and down direction; 
  3. the (1, 3) cell and left direction; 
  4. the (1, 3) cell and down direction; 
  5. the (1, 4) cell and left direction; 
  6. the (2, 2) cell and left direction; 
  7. the (2, 2) cell and up direction; 
  8. the (2, 2) and right direction; 
  9. the (2, 4) cell and left direction. 



Therefore, there are 9 good positions in this example.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  return a ? gcd(b % a, a) : b;
}
template <typename T>
T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
string int_to_str_easy(long long n) {
  return n ? "" : int_to_str_easy(n / 10) + (char)('0' + n % 10);
}
template <typename T>
T sum(vector<T> v) {
  T ans = 0;
  for (T i : v) ans += i;
  return ans;
}
template <typename T>
bool is_prime_sqrt(T n) {
  if (n == 1) return false;
  T k = trunc(sqrt(n));
  for (T i = 2; i <= k; i++)
    if (n % i == 0) return false;
  return true;
}
bool is_down(char x) { return ('a' <= x && x <= 'z'); }
bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
bool is_digit(char x) { return ('0' <= x && x <= '9'); }
string follow(string s) {
  for (int i = 0; i < s.length(); i++)
    if (is_upper(s[i])) s[i] += 'a' - 'A';
  return s;
}
const long double pi = 3.141592653589793238462643383279;
const long double log23 = 1.58496250072115618145373894394781;
const long double eps = 1e-8;
const long double zero = 0;
const long long INF = 1e18;
const int COUT = 30;
const int prost = 239;
const long long prost64 = 239;
const int two = 2;
const long long sr = 31;
const long long MOD = 1000000007;
const int BIG = 1e9;
const int alf = 26;
const int MAX_N = 2 * 1e5 + 1;
const int MAX_M = 1001;
const int km = (1 << 18) - 1;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int bit_max = 32;
const string str_alf = "abcdefghijklmnopqrstuvwxyz";
const string str_alf_big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
void solve() { return; }
int n, m, a[MAX_M][MAX_M];
bool dp[4][MAX_M][MAX_M];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &a[i][j]);
  for (int i = 0; i < n; i++) {
    dp[0][i][0] = false;
    for (int j = 1; j < m; j++) {
      if (dp[0][i][j - 1]) {
        dp[0][i][j] = true;
        continue;
      }
      dp[0][i][j] = (a[i][j - 1] == 1);
    }
    dp[1][i][m - 1] = false;
    for (int j = m - 2; j >= 0; j--) {
      if (dp[1][i][j + 1]) {
        dp[1][i][j] = true;
        continue;
      }
      dp[1][i][j] = (a[i][j + 1] == 1);
    }
  }
  for (int i = 0; i < m; i++) {
    dp[2][0][i] = false;
    for (int j = 1; j < n; j++) {
      if (dp[2][j - 1][i]) {
        dp[2][j][i] = true;
        continue;
      }
      dp[2][j][i] = (a[j - 1][i] == 1);
    }
    dp[3][n - 1][i] = false;
    for (int j = n - 2; j >= 0; j--) {
      if (dp[3][j + 1][i]) {
        dp[3][j][i] = true;
        continue;
      }
      dp[3][j][i] = (a[j + 1][i] == 1);
    }
  }
  int ans = 0;
  for (int h = 0; h < 4; h++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (a[i][j] == 0 && dp[h][i][j]) ans++;
  cout << ans;
  return 0;
}

```