#include <bits/stdc++.h>
using namespace std;
const int MAX = 400 + 10;
const int inf = 0x3f3f3f3f;
int dp[MAX][MAX][10];
int d1[][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
int d2[][2] = {{1, 1}, {1, -1}, {-1, -1}, {-1, 1}};
int dt[][2] = {{-1, 0}, {-1, 1}, {0, 1},  {1, 1},
               {1, 0},  {1, -1}, {0, -1}, {-1, -1}};
int n, m;
long long ans;
char str[MAX][MAX];
int check(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }
int dfs(int x, int y, int d) {
  if (!check(x, y)) return 0;
  if (dp[x][y][d] != -1) return dp[x][y][d];
  if (str[x][y] == '1') return 0;
  int ret = 0;
  ret = dfs(x + dt[d][0], y + dt[d][1], d) + 1;
  return dp[x][y][d] = ret;
}
int main() {
  while (scanf("%d %d", &n, &m) == 2) {
    for (int i = 0; i < n; i++) scanf("%s", str[i]);
    memset(dp, -1, sizeof(dp));
    ans = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        for (int k = 0; k < 8; k++) dfs(i, j, k);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (str[i][j] == '0') {
          for (int k = 0; k < 4; k++) {
            int dx1 = i, dx2 = i;
            int dy1 = j, dy2 = j;
            dx1 += d1[k][0];
            dy1 += d1[k][1];
            dx2 += d1[(k + 1) % 4][0];
            dy2 += d1[(k + 1) % 4][1];
            while (check(dx1, dy1) && check(dx2, dy2) && str[dx1][dy1] == '0' &&
                   str[dx2][dy2] == '0') {
              if (k == 0 && dp[dx1][dy1][5] >= dy1 - j + 1) ans++;
              if (k == 1 && dp[dx1][dy1][7] >= dx1 - i + 1) ans++;
              if (k == 2 && dp[dx1][dy1][1] >= j - dy1 + 1) ans++;
              if (k == 3 && dp[dx1][dy1][3] >= i - dx1 + 1) ans++;
              dx1 += d1[k][0];
              dx2 += d1[(k + 1) % 4][0];
              dy1 += d1[k][1];
              dy2 += d1[(k + 1) % 4][1];
            }
          }
          for (int k = 0; k < 4; k++) {
            int dx1 = i, dx2 = i;
            int dy1 = j, dy2 = j;
            dx1 += d2[k][0];
            dy1 += d2[k][1];
            dx2 += d2[(k + 1) % 4][0];
            dy2 += d2[(k + 1) % 4][1];
            while (check(dx1, dy1) && check(dx2, dy2) && str[dx1][dy1] == '0' &&
                   str[dx2][dy2] == '0') {
              if (k == 0 && dp[dx1][dy1][6] >= 2 * (dx1 - i) + 1) ans++;
              if (k == 1 && dp[dx1][dy1][0] >= 2 * (j - dy1) + 1) ans++;
              if (k == 2 && dp[dx1][dy1][2] >= 2 * (i - dx1) + 1) ans++;
              if (k == 3 && dp[dx1][dy1][4] >= 2 * (dy1 - j) + 1) ans++;
              dx1 += d2[k][0];
              dx2 += d2[(k + 1) % 4][0];
              dy1 += d2[k][1];
              dy2 += d2[(k + 1) % 4][1];
            }
          }
        }
    printf("%I64d\n", ans);
  }
  return 0;
}
