#include <bits/stdc++.h>
using namespace std;
const int MAX = 405;
int par[4][MAX][MAX], a[MAX][MAX];
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      a[i][j] = c - '0';
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      par[0][i][j] = par[0][i][j - 1] + a[i][j];
      par[1][i][j] = par[1][i - 1][j] + a[i][j];
      par[2][i][j] = par[2][i - 1][j - 1] + a[i][j];
      par[3][i][j] = par[3][i - 1][j + 1] + a[i][j];
    }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int l = 1; l <= m; l++)
      for (int r = l + 1; r <= m; r++) {
        int x, y;
        x = i - (r - l);
        y = r;
        if (1 <= x && x <= n && 1 <= y && y <= m)
          if (par[0][i][r] - par[0][i][l - 1] == 0)
            if (par[1][i][r] - par[1][x - 1][y] == 0)
              if (par[3][i][l] - par[3][x - 1][y + 1] == 0) ans++;
        x = i - (r - l);
        y = l;
        if (1 <= x && x <= n && 1 <= y && y <= m)
          if (par[0][i][r] - par[0][i][l - 1] == 0)
            if (par[1][i][l] - par[1][x - 1][y] == 0)
              if (par[2][i][r] - par[2][x - 1][y - 1] == 0) ans++;
        x = i + (r - l);
        y = r;
        if (1 <= x && x <= n && 1 <= y && y <= m)
          if (par[0][i][r] - par[0][i][l - 1] == 0)
            if (par[1][x][y] - par[1][i - 1][r] == 0)
              if (par[2][x][y] - par[2][i - 1][l - 1] == 0) ans++;
        x = i + (r - l);
        y = l;
        if (1 <= x && x <= n && 1 <= y && y <= m)
          if (par[0][i][r] - par[0][i][l - 1] == 0)
            if (par[1][x][y] - par[1][i - 1][l] == 0)
              if (par[3][x][y] - par[3][i - 1][r + 1] == 0) ans++;
        int dif = (r - l) / 2;
        if (dif * 2 == r - l) {
          x = i - dif;
          y = l + dif;
          if (1 <= x && x <= n && 1 <= y && y <= m)
            if (par[0][i][r] - par[0][i][l - 1] == 0)
              if (par[3][i][l] - par[3][x - 1][y + 1] == 0)
                if (par[2][i][r] - par[2][x - 1][y - 1] == 0) ans++;
          x = i + dif;
          y = l + dif;
          if (1 <= x && x <= n && 1 <= y && y <= m)
            if (par[0][i][r] - par[0][i][l - 1] == 0)
              if (par[3][x][y] - par[3][i - 1][r + 1] == 0)
                if (par[2][x][y] - par[2][i - 1][l - 1] == 0) ans++;
        }
      }
  for (int j = 1; j <= m; j++)
    for (int u = 1; u <= n; u++)
      for (int d = u + 1; d <= n; d++) {
        int dif = (d - u) / 2;
        if (dif * 2 != d - u) continue;
        int x, y;
        x = u + dif;
        y = j - dif;
        if (1 <= x && x <= n && 1 <= y && y <= m)
          if (par[1][d][j] - par[1][u - 1][j] == 0)
            if (par[3][x][y] - par[3][u - 1][j + 1] == 0)
              if (par[2][d][j] - par[2][x - 1][y - 1] == 0) ans++;
        x = u + dif;
        y = j + dif;
        if (1 <= x && x <= n && 1 <= y && y <= m)
          if (par[1][d][j] - par[1][u - 1][j] == 0)
            if (par[2][x][y] - par[2][u - 1][j - 1] == 0)
              if (par[3][d][j] - par[3][x - 1][y + 1] == 0) ans++;
      }
  cout << ans << endl;
  return 0;
}
