#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 4e18;
const int N = 405;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int n, m, hor[N][N], ver[N][N], diag[N][N], a[N][N];
int ans = 0;
void putar(void) {
  int temp[N][N], i, j;
  for (i = 0; i < n; ++i)
    for (j = 0; j < m; ++j) temp[j][n - i - 1] = a[i][j];
  for (i = 0; i < m; ++i)
    for (j = 0; j < n; ++j) a[i][j] = temp[i][j];
  swap(n, m);
}
int kaki(int k, int l) {
  int cur = 0, r = 1;
  while (ver[k + 2 * r][l] == ver[k][l] && !a[k + r][l + r] && k + 2 * r < n &&
         l + r < m) {
    if (diag[k + r][l + r] == diag[k + 2 * r][l]) cur++;
    r++;
  }
  return cur;
}
int siku(int k, int l) {
  int cur = 0;
  int kk = k + 1, ll = l + 1;
  while (!a[kk][l] && !a[kk][ll] && kk < n && ll < m) {
    if (hor[kk][l - 1] == hor[kk][ll]) cur++;
    kk++;
    ll++;
  }
  return cur;
}
void do_it(void) {
  memset(hor, 0, sizeof(hor));
  memset(ver, 0, sizeof(ver));
  memset(diag, 0, sizeof(diag));
  int i, j;
  for (i = 0; i < n; ++i)
    for (j = 0; j < m; ++j) hor[i][j] = hor[i][j - 1] + a[i][j];
  for (i = 0; i < n; ++i)
    for (j = 0; j < m; ++j) ver[i][j] = ver[i - 1][j] + a[i][j];
  for (i = 0; i < n; ++i)
    for (j = 0; j < m; ++j) diag[i][j] = diag[i - 1][j + 1] + a[i][j];
  for (i = 0; i < n; ++i)
    for (j = 0; j < m; ++j)
      if (!a[i][j]) ans += kaki(i, j) + siku(i, j);
}
int main(void) {
  scanf("%d %d", &n, &m);
  int i, j, l;
  for (i = 0; i < n; ++i) {
    char x[405];
    scanf("%s", x);
    for (j = 0; j < m; ++j) {
      a[i][j] = x[j] - '0';
    }
  }
  for (i = 0; i < 4; ++i) {
    putar();
    do_it();
  }
  printf("%d\n", ans);
  return 0;
}
