#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long double EPS = 1e-9;
const long double pi = acos(-1.0);
const int MAXN = (int)1e5 + 7;
const int INF = (int)1e9;
const long long LINF = (long long)7e18;
const long long MOD = (long long)1e9 + 7;
const int CHASH = (long long)239017;
const long double DINF = (long double)1000000000000000.0;
void mkfile();
int solve();
int main() {
  srand(228);
  solve();
  return 0;
}
void mkfile() {
  freopen("input.txt", "a+", stdout);
  srand(time(0));
  return;
}
bool equal(double a, double b) { return abs(a - b) < EPS; }
struct Point {
  double x, y;
  int id;
  Point(){};
  Point(double x, double y) : x(x), y(y){};
  Point operator*(double d) { return Point(x * d, y * d); }
  Point operator+(Point p) { return Point(x + p.x, y + p.y); }
  Point operator-(Point p) { return Point(x - p.x, y - p.y); }
  double operator%(Point p) { return x * p.x + y * p.y; }
  double operator*(Point p) { return x * p.y - y * p.x; }
  bool operator==(Point p) { return equal(x, p.x) && equal(y, p.y); }
  double distancetoPoint(Point p) {
    return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));
  }
  double len() { return sqrt(x * x + y * y); }
  double angle(Point p) { return atan2((*this) * p, (*this) % p); }
  Point turnByAngle(double a) {
    double cosa = cos(a);
    double sina = sin(a);
    return Point(x * cosa - y * sina, x * sina + y * cosa);
  }
  Point getNormVec() { return Point(x / (*this).len(), y / (*this).len()); }
};
Point makeV(Point a, Point b) { return a - b; }
const Point NULLP = Point(1e9 + 7, 1e9 + 9);
const Point EQ = Point(13888, 888283);
const Point INFPTS = Point(1e9 + 17, 1e9 + 19);
struct Line {
  double a, b, c;
  Point q, w;
  Line(){};
  Line(double a, double b, double c) : a(a), b(b), c(c){};
  Line(Point p, Point t) {
    a = t.y - p.y;
    b = p.x - t.x;
    c = -a * p.x - b * p.y;
    q = p;
    w = t;
  }
  bool eq_null(Line l) { return (l.a == a) && (l.b == b) && (l.c == c); }
  double distanceFromPoint(Point p) {
    return (a * p.x + b * p.y + c) / Point(a, b).len();
  }
  bool operator||(Line l) { return equal(Point(a, b) * Point(l.a, l.b), 0); }
  bool ifeq(Line l) {
    Point v1 = makeV(q, w);
    Point v2 = makeV(l.q, l.w);
    Point v11 = makeV(l.w, w);
    Point v22 = makeV(q, l.q);
    if (v1 * v2 == 0 && v11 * v22 == 0) return 1;
    return 0;
  }
  Point operator^(Line l) {
    double d = Point(a, b) * Point(l.a, l.b);
    if (equal(d, 0)) return NULLP;
    double x = (b * l.c - l.b * c) / d;
    double y = (c * l.a - l.c * a) / d;
    return Point(x, y);
  }
};
istream &operator>>(istream &input_stream, Point &a) {
  input_stream >> a.x >> a.y;
  return input_stream;
}
istream &operator>>(istream &input_stream, Line &a) {
  input_stream >> a.a >> a.b >> a.c;
  return input_stream;
}
ostream &operator<<(ostream &output_stream, Point &a) {
  output_stream.precision(15);
  output_stream << fixed << a.x << " " << a.y;
  return output_stream;
}
const int Q = 1007;
int n, m;
int a[Q][Q];
int ls[Q][Q], rs[Q][Q], us[Q][Q], ds[Q][Q];
int solve() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < (int)n; i++)
    for (int j = 0; j < (int)m; j++) scanf("%d", &a[i][j]);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      ls[i][j] = a[i][j];
      if (j) ls[i][j] += ls[i][j - 1];
    }
    for (int j = m - 1; j >= 0; --j) {
      rs[i][j] = a[i][j];
      if (j != m - 1) rs[i][j] += rs[i][j + 1];
    }
  }
  for (int j = 0; j < m; ++j) {
    for (int i = 0; i < n; ++i) {
      us[i][j] = a[i][j];
      if (i) us[i][j] += us[i - 1][j];
    }
    for (int i = n - 1; i >= 0; --i) {
      ds[i][j] = a[i][j];
      if (i != n - 1) ds[i][j] += ds[i + 1][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      if (!a[i][j]) {
        ans +=
            (us[i][j] > 0) + (ds[i][j] > 0) + (ls[i][j] > 0) + (rs[i][j] > 0);
      }
    }
  cout << ans;
  return 0;
}

### Prompt

Your challenge is to write a cpp solution to the following problem:

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>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long double EPS = 1e-9;
const long double pi = acos(-1.0);
const int MAXN = (int)1e5 + 7;
const int INF = (int)1e9;
const long long LINF = (long long)7e18;
const long long MOD = (long long)1e9 + 7;
const int CHASH = (long long)239017;
const long double DINF = (long double)1000000000000000.0;
void mkfile();
int solve();
int main() {
  srand(228);
  solve();
  return 0;
}
void mkfile() {
  freopen("input.txt", "a+", stdout);
  srand(time(0));
  return;
}
bool equal(double a, double b) { return abs(a - b) < EPS; }
struct Point {
  double x, y;
  int id;
  Point(){};
  Point(double x, double y) : x(x), y(y){};
  Point operator*(double d) { return Point(x * d, y * d); }
  Point operator+(Point p) { return Point(x + p.x, y + p.y); }
  Point operator-(Point p) { return Point(x - p.x, y - p.y); }
  double operator%(Point p) { return x * p.x + y * p.y; }
  double operator*(Point p) { return x * p.y - y * p.x; }
  bool operator==(Point p) { return equal(x, p.x) && equal(y, p.y); }
  double distancetoPoint(Point p) {
    return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));
  }
  double len() { return sqrt(x * x + y * y); }
  double angle(Point p) { return atan2((*this) * p, (*this) % p); }
  Point turnByAngle(double a) {
    double cosa = cos(a);
    double sina = sin(a);
    return Point(x * cosa - y * sina, x * sina + y * cosa);
  }
  Point getNormVec() { return Point(x / (*this).len(), y / (*this).len()); }
};
Point makeV(Point a, Point b) { return a - b; }
const Point NULLP = Point(1e9 + 7, 1e9 + 9);
const Point EQ = Point(13888, 888283);
const Point INFPTS = Point(1e9 + 17, 1e9 + 19);
struct Line {
  double a, b, c;
  Point q, w;
  Line(){};
  Line(double a, double b, double c) : a(a), b(b), c(c){};
  Line(Point p, Point t) {
    a = t.y - p.y;
    b = p.x - t.x;
    c = -a * p.x - b * p.y;
    q = p;
    w = t;
  }
  bool eq_null(Line l) { return (l.a == a) && (l.b == b) && (l.c == c); }
  double distanceFromPoint(Point p) {
    return (a * p.x + b * p.y + c) / Point(a, b).len();
  }
  bool operator||(Line l) { return equal(Point(a, b) * Point(l.a, l.b), 0); }
  bool ifeq(Line l) {
    Point v1 = makeV(q, w);
    Point v2 = makeV(l.q, l.w);
    Point v11 = makeV(l.w, w);
    Point v22 = makeV(q, l.q);
    if (v1 * v2 == 0 && v11 * v22 == 0) return 1;
    return 0;
  }
  Point operator^(Line l) {
    double d = Point(a, b) * Point(l.a, l.b);
    if (equal(d, 0)) return NULLP;
    double x = (b * l.c - l.b * c) / d;
    double y = (c * l.a - l.c * a) / d;
    return Point(x, y);
  }
};
istream &operator>>(istream &input_stream, Point &a) {
  input_stream >> a.x >> a.y;
  return input_stream;
}
istream &operator>>(istream &input_stream, Line &a) {
  input_stream >> a.a >> a.b >> a.c;
  return input_stream;
}
ostream &operator<<(ostream &output_stream, Point &a) {
  output_stream.precision(15);
  output_stream << fixed << a.x << " " << a.y;
  return output_stream;
}
const int Q = 1007;
int n, m;
int a[Q][Q];
int ls[Q][Q], rs[Q][Q], us[Q][Q], ds[Q][Q];
int solve() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < (int)n; i++)
    for (int j = 0; j < (int)m; j++) scanf("%d", &a[i][j]);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      ls[i][j] = a[i][j];
      if (j) ls[i][j] += ls[i][j - 1];
    }
    for (int j = m - 1; j >= 0; --j) {
      rs[i][j] = a[i][j];
      if (j != m - 1) rs[i][j] += rs[i][j + 1];
    }
  }
  for (int j = 0; j < m; ++j) {
    for (int i = 0; i < n; ++i) {
      us[i][j] = a[i][j];
      if (i) us[i][j] += us[i - 1][j];
    }
    for (int i = n - 1; i >= 0; --i) {
      ds[i][j] = a[i][j];
      if (i != n - 1) ds[i][j] += ds[i + 1][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      if (!a[i][j]) {
        ans +=
            (us[i][j] > 0) + (ds[i][j] > 0) + (ls[i][j] > 0) + (rs[i][j] > 0);
      }
    }
  cout << ans;
  return 0;
}

```