#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,1024000")
using namespace std;
int Map[410][410];
int ans[4][410][410];
int jx[] = {-1, -1, 0, 1};
int jy[] = {0, -1, -1, -1};
bool Cal(int x1, int y1, int x2, int y2, int n, int m, int dir) {
  if (1 <= x1 && x1 <= n && 1 <= x2 && x2 <= n) {
    if (1 <= y1 && y1 <= m && 1 <= y2 && y2 <= m) {
      if (ans[dir][x1][y1] - ans[dir][x2 + jx[dir]][y2 + jy[dir]] == 0)
        return true;
    }
  }
  return false;
}
int main() {
  int n, m;
  int i, j, k, t1, t2, t3, t4;
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j) scanf("%1d", &Map[i][j]);
  memset(ans, 0, sizeof(ans));
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j)
      for (k = 0; k < 3; ++k)
        ans[k][i][j] = ans[k][i + jx[k]][j + jy[k]] + Map[i][j];
  for (i = n; i >= 1; --i)
    for (j = 1; j <= m; ++j) ans[3][i][j] = ans[3][i + 1][j - 1] + Map[i][j];
  int sum = 0;
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j) {
      if (Map[i][j]) continue;
      for (k = 1; k < min(n, m); ++k) {
        int x = i, y = j;
        sum += Cal(x, y, x - k, y, n, m, 0) && Cal(x, y, x, y - k, n, m, 2) &&
                       Cal(x - k, y, x, y - k, n, m, 3)
                   ? 1
                   : 0;
        sum += Cal(x, y, x - k, y, n, m, 0) && Cal(x, y + k, x, y, n, m, 2) &&
                       Cal(x, y + k, x - k, y, n, m, 1)
                   ? 1
                   : 0;
        sum += Cal(x, y + k, x, y, n, m, 2) && Cal(x + k, y, x, y, n, m, 0) &&
                       Cal(x, y + k, x + k, y, n, m, 3)
                   ? 1
                   : 0;
        sum += Cal(x, y, x, y - k, n, m, 2) && Cal(x + k, y, x, y, n, m, 0) &&
                       Cal(x + k, y, x, y - k, n, m, 1)
                   ? 1
                   : 0;
        sum += Cal(x - k, y, x, y - k, n, m, 3) &&
                       Cal(x, y + k, x, y - k, n, m, 2) &&
                       Cal(x, y + k, x - k, y, n, m, 1)
                   ? 1
                   : 0;
        sum += Cal(x + k, y, x - k, y, n, m, 0) &&
                       Cal(x, y + k, x - k, y, n, m, 1) &&
                       Cal(x, y + k, x + k, y, n, m, 3)
                   ? 1
                   : 0;
        sum += Cal(x, y + k, x, y - k, n, m, 2) &&
                       Cal(x, y + k, x + k, y, n, m, 3) &&
                       Cal(x + k, y, x, y - k, n, m, 1)
                   ? 1
                   : 0;
        sum += Cal(x + k, y, x - k, y, n, m, 0) &&
                       Cal(x + k, y, x, y - k, n, m, 1) &&
                       Cal(x - k, y, x, y - k, n, m, 3)
                   ? 1
                   : 0;
      }
    }
  printf("%d\n", sum);
  return 0;
}
