#include <bits/stdc++.h>
using namespace std;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int ext[404][404][8];
int n, m;
char s[404][404];
bool ok(int x, int y) {
  return x > 0 && x <= n && y > 0 && y <= m && s[x][y] == '0';
}
int ans;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = (1); i <= (n); i++) scanf(" %s", s[i] + 1);
  for (int i = (1); i <= (n); i++)
    for (int j = (1); j <= (m); j++) {
      for (int k = (0); k <= (7); k++) {
        int cx = i, cy = j;
        int cur = 0;
        while (ok(cx, cy)) {
          cur++;
          cx += dx[k];
          cy += dy[k];
        }
        ext[i][j][k] = cur;
      }
    }
  for (int i = (1); i <= (n); i++)
    for (int j = (1); j <= (m); j++) {
      for (int k = (0); k <= (7); k++) {
        int a = k, b = (k + 2) % 8, c = (k + 3) % 8;
        int bs = min(ext[i][j][k], ext[i][j][(k + 2) % 8]);
        for (int l = (1); l <= (bs - 1); l++) {
          int cx = i + l * dx[k];
          int cy = j + l * dy[k];
          if (!ok(cx, cy)) continue;
          if (k % 2 == 0 && ext[cx][cy][(k + 3) % 8] > l) ans++;
          if (k % 2 == 1 && ext[cx][cy][(k + 3) % 8] > 2 * l) ans++;
        }
      }
    }
  printf("%d\n", ans);
  return 0;
}
