#include <bits/stdc++.h>
using namespace std;
int n, m;
char mp[444][444];
struct node {
  int num[8];
} np[444][444];
int dy[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dx[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
long long ans;
bool in(int x, int y) { return x >= 1 && x <= n && y >= 1 && y <= m; }
void cal(int x, int y) {
  for (int i = 0; i < 8; i++) {
    int xx = x;
    int yy = y;
    while (in(xx, yy) && mp[xx][yy] == '0') {
      np[x][y].num[i]++;
      xx += dx[i];
      yy += dy[i];
    }
    np[x][y].num[i]--;
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", mp[i] + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (mp[i][j] == '0') cal(i, j);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (mp[i][j] == '0') {
        long long cur = 0LL;
        node &now = np[i][j];
        for (int k = 0; k < 8; k++) {
          if (k % 2 == 0) {
            for (int l = 1; l <= now.num[k]; l++) {
              node &then = np[i + l * dx[k]][j + l * dy[k]];
              if (then.num[(k + 2) % 8] >= l && now.num[(k + 1) % 8] / 2 >= l)
                cur++;
              if (then.num[(k + 3) % 8] >= l && now.num[(k + 1) % 8] >= l)
                cur++;
              if (then.num[(k + 3) % 8] / 2 >= l && now.num[(k + 2) % 8] >= l)
                cur++;
            }
          } else {
            for (int l = 1; l <= now.num[k]; l++) {
              node &then = np[i + l * dx[k]][j + l * dy[k]];
              if (l % 2 == 0 && then.num[(k + 3) % 8] >= l / 2 &&
                  now.num[(k + 1) % 8] >= l / 2)
                cur++;
              if (then.num[(k + 2) % 8] >= l && now.num[(k + 1) % 8] >= l)
                cur++;
              if (then.num[(k + 3) % 8] >= l && now.num[(k + 2) % 8] >= l)
                cur++;
            }
          }
        }
        ans += cur;
      }
    }
  }
  printf("%I64d\n", ans / 3);
}
