#include <bits/stdc++.h>
using namespace std;
template <typename T>
using maxHeap = priority_queue<T, vector<T>, less<T>>;
template <typename T>
using minHeap = priority_queue<T, vector<T>, greater<T>>;
template <typename Iter>
ostream& _out(ostream& s, Iter b, Iter e) {
  s << "[";
  for (auto it = b; it != e; it++) s << (it == b ? "" : " ") << *it;
  s << "]";
  return s;
}
template <typename A, typename B>
ostream& operator<<(ostream& s, const pair<A, B>& p) {
  return s << "(" << p.first << "," << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, const vector<T>& c) {
  return _out(s, begin(c), end(c));
}
bool debug = 0;
template <typename T>
void DEBUG(const T& x) {
  if (debug) cerr << x;
}
template <typename T, typename... Args>
void DEBUG(const T& head, const Args&... tail) {
  if (debug) {
    cerr << head;
    DEBUG(tail...);
  }
}
const int N = 400 + 5;
bool mtx[N][N];
int hen[N][N], zhi[N][N], n, m;
bool valid(pair<int, int> pos) {
  return (1 <= pos.first and pos.first <= n) and
         (1 <= pos.second and pos.second <= m);
}
int calc1(int x, int y) {
  if (mtx[x][y]) return 0;
  int ret = 0;
  pair<int, int> a = {x - 1, y - 1}, b = {x - 1, y + 1};
  while (valid(a) and valid(b)) {
    if (mtx[a.first][a.second] or mtx[b.first][b.second]) break;
    if (hen[a.first][b.second] - hen[a.first][a.second - 1] == 0) ret++;
    a.first--, a.second--;
    b.first--, b.second++;
  }
  return ret;
}
int calc2(int x, int y) {
  if (mtx[x][y]) return 0;
  int ret = 0;
  pair<int, int> a = {x + 1, y - 1}, b = {x + 1, y + 1};
  while (valid(a) and valid(b)) {
    if (mtx[a.first][a.second] or mtx[b.first][b.second]) break;
    if (hen[a.first][b.second] - hen[a.first][a.second - 1] == 0) ret++;
    a.first++, a.second--;
    b.first++, b.second++;
  }
  return ret;
}
int calc3(int x, int y) {
  if (mtx[x][y]) return 0;
  int ret = 0;
  pair<int, int> a = {x - 1, y - 1}, b = {x + 1, y - 1};
  while (valid(a) and valid(b)) {
    if (mtx[a.first][a.second] or mtx[b.first][b.second]) break;
    if (zhi[b.first][a.second] - zhi[a.first - 1][a.second] == 0) ret++;
    a.first--, a.second--;
    b.first++, b.second--;
  }
  return ret;
}
int calc4(int x, int y) {
  if (mtx[x][y]) return 0;
  int ret = 0;
  pair<int, int> a = {x - 1, y + 1}, b = {x + 1, y + 1};
  while (valid(a) and valid(b)) {
    if (mtx[a.first][a.second] or mtx[b.first][b.second]) break;
    if (zhi[b.first][a.second] - zhi[a.first - 1][a.second] == 0) ret++;
    a.first--, a.second++;
    b.first++, b.second++;
  }
  return ret;
}
int calc5(int x, int y) {
  if (mtx[x][y]) return 0;
  int ret = 0;
  pair<int, int> a = {x + 1, y - 1}, b = {x + 1, y};
  while (valid(a) and valid(b)) {
    if (mtx[a.first][a.second] or mtx[b.first][b.second]) break;
    if (hen[a.first][b.second] - hen[a.first][a.second - 1] == 0) ret++;
    a.first++, a.second--;
    b.first++;
  }
  return ret;
}
int calc6(int x, int y) {
  if (mtx[x][y]) return 0;
  int ret = 0;
  pair<int, int> a = {x + 1, y}, b = {x + 1, y + 1};
  while (valid(a) and valid(b)) {
    if (mtx[a.first][a.second] or mtx[b.first][b.second]) break;
    if (hen[a.first][b.second] - hen[a.first][a.second - 1] == 0) ret++;
    a.first++;
    b.first++, b.second++;
  }
  return ret;
}
int calc7(int x, int y) {
  if (mtx[x][y]) return 0;
  int ret = 0;
  pair<int, int> a = {x - 1, y}, b = {x - 1, y + 1};
  while (valid(a) and valid(b)) {
    if (mtx[a.first][a.second] or mtx[b.first][b.second]) break;
    if (hen[a.first][b.second] - hen[a.first][a.second - 1] == 0) ret++;
    a.first--;
    b.first--, b.second++;
  }
  return ret;
}
int calc8(int x, int y) {
  if (mtx[x][y]) return 0;
  int ret = 0;
  pair<int, int> a = {x - 1, y - 1}, b = {x - 1, y};
  while (valid(a) and valid(b)) {
    if (mtx[a.first][a.second] or mtx[b.first][b.second]) break;
    if (hen[a.first][b.second] - hen[a.first][a.second - 1] == 0) ret++;
    a.first--, a.second--;
    b.first--;
  }
  return ret;
}
int main(int argc, char* argv[]) {
  if (argc > 1 and string(argv[1]) == "-D") debug = 1;
  if (!debug) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  }
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    string ss;
    cin >> ss;
    for (int j = 1; j <= m; j++) mtx[i][j] = ss[j - 1] - '0';
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      hen[i][j] = hen[i][j - 1] + mtx[i][j];
      zhi[i][j] = zhi[i - 1][j] + mtx[i][j];
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cnt += calc1(i, j);
      cnt += calc2(i, j);
      cnt += calc3(i, j);
      cnt += calc4(i, j);
      cnt += calc5(i, j);
      cnt += calc6(i, j);
      cnt += calc7(i, j);
      cnt += calc8(i, j);
    }
  cout << cnt << '\n';
  return 0;
}
