#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int iinf = 1 << 29;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
long long mrand(long long B) { return (unsigned long long)rng() % B; }
long long cross(pair<long long, long long> p1, pair<long long, long long> p2) {
  return p1.first * p2.second - p2.first * p1.second;
}
bool online(pair<long long, long long> a, pair<long long, long long> b,
            pair<long long, long long> c) {
  pair<long long, long long> p1{b.first - a.first, b.second - a.second};
  pair<long long, long long> p2{c.first - a.first, c.second - a.second};
  return cross(p1, p2) == 0;
}
void z_func(vector<int> &z, vector<int> &s, int n) {
  int L = 0, R = 0;
  for (int i = 1; i < n; i++) {
    if (i > R) {
      L = R = i;
      while (R < n && s[R - L] == s[R]) R++;
      z[i] = R - L;
      R--;
    } else {
      int k = i - L;
      if (z[k] < R - i + 1)
        z[i] = z[k];
      else {
        L = i;
        while (R < n && s[R - L] == s[R]) R++;
        z[i] = R - L;
        R--;
      }
    }
  }
}
const int MXN = 400;
long long ans;
int n, m;
int v[MXN][MXN], up[MXN][MXN], down[MXN][MXN], leftt[MXN][MXN],
    rightt[MXN][MXN], ul[MXN][MXN], ur[MXN][MXN], lol[MXN][MXN], lr[MXN][MXN];
void populate() {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (!v[i][j]) continue;
      if (i && v[i - 1][j]) up[i][j] = 1 + up[i - 1][j];
      if (j && v[i][j - 1]) leftt[i][j] = 1 + leftt[i][j - 1];
      if (i && j && v[i - 1][j - 1]) ul[i][j] = 1 + ul[i - 1][j - 1];
      if (i && j != m - 1 && v[i - 1][j + 1]) ur[i][j] = 1 + ur[i - 1][j + 1];
    }
  }
  for (int i = n - 1; i >= 0; --i) {
    for (int j = m - 1; j >= 0; --j) {
      if (!v[i][j]) continue;
      if (i != n - 1 && v[i + 1][j]) down[i][j] = 1 + down[i + 1][j];
      if (j != m - 1 && v[i][j + 1]) rightt[i][j] = 1 + rightt[i][j + 1];
      if (i != n - 1 && j != m - 1 && v[i + 1][j + 1])
        lr[i][j] = 1 + lr[i + 1][j + 1];
      if (i != n - 1 && j && v[i + 1][j - 1]) lol[i][j] = 1 + lol[i + 1][j - 1];
    }
  }
}
void do_lower_leftt(int x, int y) {
  for (int i = x + 1, j = y - 1; i < n && j >= 0 && v[i][j]; ++i, --j) {
    ans += down[x][y] >= 2 * (i - x) && lr[i][j] >= i - x;
    ans += down[x][y] >= i - x && rightt[i][j] >= y - j;
    ans += lr[x][y] >= i - x && rightt[i][j] >= 2 * (y - j);
  }
}
void do_down(int x, int y) {
  for (int i = x + 1; i < n && v[i][y]; ++i) {
    ans += lr[x][y] >= i - x && rightt[i][y] >= i - x;
    ans += rightt[x][y] >= i - x && ur[i][y] >= i - x;
    ans +=
        (i - x) % 2 == 0 && lr[x][y] >= (i - x) / 2 && ur[i][y] >= (i - x) / 2;
  }
}
void do_lower_rightt(int x, int y) {
  for (int i = x + 1, j = y + 1; i < n && j < m && v[i][j]; ++i, ++j) {
    ans += rightt[x][y] >= j - y && up[i][j] >= i - x;
    ans += rightt[x][y] >= 2 * (j - y) && ur[i][j] >= i - x;
  }
}
void work() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      char c;
      cin >> c;
      while (c != '0' && c != '1') cin >> c;
      v[i][j] = c == '0' ? 1 : 0;
    }
  populate();
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (!v[i][j]) continue;
      do_lower_leftt(i, j);
      do_down(i, j);
      do_lower_rightt(i, j);
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  work();
  return 0;
}
