#include <bits/stdc++.h>
using namespace std;
char str[500][500];
int Move1[][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
int Move2[][2] = {{1, 1}, {1, -1}, {-1, -1}, {-1, 1}};
int Move[][2] = {{-1, 0}, {-1, 1}, {0, 1},  {1, 1},
                 {1, 0},  {1, -1}, {0, -1}, {-1, -1}};
int dp[500][500][8];
int n, m;
bool inside(int x, int y) { return (x >= 0 && x < n && y >= 0 && y < m); }
int dfs(int x, int y, int d) {
  if (!inside(x, y)) return 0;
  if (dp[x][y][d] != -1) return dp[x][y][d];
  if (str[x][y] == '1') return dp[x][y][d] = 0;
  return dp[x][y][d] = dfs(x + Move[d][0], y + Move[d][1], d) + 1;
}
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));
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        for (int k = 0; k < 8; k++) {
          int tmp = dfs(i, j, k);
        }
    long long ans = 0;
    for (int x = 0; x < n; x++)
      for (int y = 0; y < m; y++)
        if (str[x][y] == '0') {
          for (int i = 0; i < 4; i++) {
            int xx1 = x, yy1 = y;
            int xx2 = x, yy2 = y;
            xx1 += Move1[i][0];
            yy1 += Move1[i][1];
            xx2 += Move1[(i + 1) % 4][0];
            yy2 += Move1[(i + 1) % 4][1];
            while (inside(xx1, yy1) && inside(xx2, yy2) &&
                   str[xx1][yy1] == '0' && str[xx2][yy2] == '0') {
              if (i == 0 && dp[xx1][yy1][5] >= yy1 - y + 1) ans++;
              if (i == 1 && dp[xx1][yy1][7] >= xx1 - x + 1) ans++;
              if (i == 2 && dp[xx1][yy1][1] >= y - yy1 + 1) ans++;
              if (i == 3 && dp[xx1][yy1][3] >= x - xx1 + 1) ans++;
              xx1 += Move1[i][0];
              yy1 += Move1[i][1];
              xx2 += Move1[(i + 1) % 4][0];
              yy2 += Move1[(i + 1) % 4][1];
            }
          }
          for (int i = 0; i < 4; i++) {
            int xx1 = x, yy1 = y;
            int xx2 = x, yy2 = y;
            xx1 += Move2[i][0];
            yy1 += Move2[i][1];
            xx2 += Move2[(i + 1) % 4][0];
            yy2 += Move2[(i + 1) % 4][1];
            while (inside(xx1, yy1) && inside(xx2, yy2) &&
                   str[xx1][yy1] == '0' && str[xx2][yy2] == '0') {
              if (i == 0 && dp[xx1][yy1][6] >= 2 * (xx1 - x) + 1) ans++;
              if (i == 1 && dp[xx1][yy1][0] >= 2 * (y - yy1) + 1) ans++;
              if (i == 2 && dp[xx1][yy1][2] >= 2 * (x - xx1) + 1) ans++;
              if (i == 3 && dp[xx1][yy1][4] >= 2 * (yy1 - y) + 1) ans++;
              xx1 += Move2[i][0];
              yy1 += Move2[i][1];
              xx2 += Move2[(i + 1) % 4][0];
              yy2 += Move2[(i + 1) % 4][1];
            }
          }
        }
    cout << ans << endl;
  }
  return 0;
}
