#include <bits/stdc++.h>
using namespace std;
int f[510][510][10];
int a[510][510];
int dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      char ch;
      cin >> ch;
      a[i][j] = ch - '0';
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int k = 0; k < 4; k++) {
        int x = i, y = j;
        while (x > 0 && x <= n && y > 0 && y <= m && a[x][y] != 1)
          x += dx[k], y += dy[k];
        f[i][j][k] = (i - x != 0 ? i - x : j - y);
      }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j] == 0) {
        for (int k = 0; k < 8; k++) {
          int p = (k + 2) % 8, q = (k + 3) % 4;
          for (int t = 1; t < min(n, m); t++) {
            int xp = i + t * dx[k], yp = j + t * dy[k], xq = i + t * dx[p],
                yq = j + t * dy[p];
            if (xp <= 0 || xp > n || yp <= 0 || yp > m || xq <= 0 || xq > n ||
                yq <= 0 || yq > m || a[xp][yp] == 1 || a[xq][yq] == 1)
              break;
            if (k >= 1 && k <= 4) {
              if ((dx[q] == 0 || f[xq][yq][q] >= (xp - xq) / dx[q]) &&
                  (dy[q] == 0 || f[xq][yq][q] >= (yp - yq) / dy[q]))
                ans++;
            } else {
              if ((dx[q] == 0 || f[xp][yp][q] >= (xq - xp) / dx[q]) &&
                  (dy[q] == 0 || f[xp][yp][q] >= (yq - yp) / dy[q]))
                ans++;
            }
          }
        }
      }
  cout << ans << endl;
  return 0;
}
