#include <bits/stdc++.h>
using namespace std;
const int maxn = 440;
int UP[maxn][maxn];
int LEFT[maxn][maxn];
int UPLEFT[maxn][maxn];
int UPRIGHT[maxn][maxn];
char mat[maxn][maxn];
int M[maxn][maxn];
int tmp[maxn][maxn];
int n, m;
int ans = 0;
void myrotate() {
  memset(tmp, 0, sizeof(tmp));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) tmp[j][i] = M[i][j];
  swap(n, m);
  memset(M, 0, sizeof(M));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) M[i][j] = tmp[n + 1 - i][j];
}
void solve() {
  memset(UP, 0, sizeof(UP));
  memset(LEFT, 0, sizeof(LEFT));
  memset(UPLEFT, 0, sizeof(UPLEFT));
  memset(UPRIGHT, 0, sizeof(UPRIGHT));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (M[i][j]) {
        UP[i][j] = UP[i - 1][j] + 1;
        LEFT[i][j] = LEFT[i][j - 1] + 1;
        UPLEFT[i][j] = UPLEFT[i - 1][j - 1] + 1;
      }
  for (int i = 1; i <= n; i++)
    for (int j = m; j >= 1; j--)
      if (M[i][j]) {
        UPRIGHT[i][j] = UPRIGHT[i - 1][j + 1] + 1;
      }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int sz = 1; sz <= min(m, n); sz++) {
        if (i + sz > n) continue;
        if (sz >= j) continue;
        if (LEFT[i][j] < sz + 1) continue;
        if (UP[i + sz][j - sz] < sz + 1) continue;
        if (UPRIGHT[i + sz][j - sz] < sz + 1) continue;
        ans++;
      }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int sz = 1; sz <= min(m, n); sz++) {
        if (j - sz < 1) continue;
        if (j + sz > m) continue;
        if (i + sz > n) continue;
        if (LEFT[i][j + sz] < sz * 2 + 1) continue;
        if (UPLEFT[i + sz][j] < sz + 1) continue;
        if (UPRIGHT[i + sz][j] < sz + 1) continue;
        ans++;
      }
}
int main() {
  scanf("%d%d", &n, &m);
  memset(M, 0, sizeof(M));
  for (int i = 1; i <= n; i++) scanf("%s", mat[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (mat[i][j] == '0')
        M[i][j] = 1;
      else
        M[i][j] = 0;
    }
  solve();
  myrotate();
  solve();
  myrotate();
  solve();
  myrotate();
  solve();
  printf("%d\n", ans);
  return 0;
}
