#include <bits/stdc++.h>
using namespace std;
bool grid[400][400];
bool initgrid[400][400];
int diag[400][400];
int vert[400][400];
long long calc1(int n, int m) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      diag[i][j] = 0;
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (grid[i][j]) {
        if (i > 0 && j > 0)
          diag[i][j] = diag[i - 1][j - 1] + 1;
        else
          diag[i][j] = 1;
      } else {
        diag[i][j] = 0;
      }
    }
  long long res = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (diag[i][j] != 0) {
        for (int k = 1; j + k < m && i - k >= 0; k++) {
          if (diag[i][j + k] >= k + 1) res++;
          if (diag[i][j + k] == 0 || diag[i - k][j] == 0) break;
        }
      }
  int z = 0;
  return res;
}
long long calc2(int n, int m) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      vert[i][j] = 0;
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (grid[i][j]) {
        if (i > 0)
          vert[i][j] = vert[i - 1][j] + 1;
        else
          vert[i][j] = 1;
      } else {
        vert[i][j] = 0;
      }
    }
  long long res = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (vert[i][j] != 0) {
        for (int k = 1; i + k < n && j + k < m && i - k >= 0; k++) {
          if (vert[i + k][j + k] >= k * 2 + 1) res++;
          if (vert[i + k][j + k] == 0 || vert[i - k][j + k] == 0) break;
        }
      }
  return res;
}
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; i++) {
    char s[500];
    scanf("%s", s);
    for (int j = 0; j < M; j++) initgrid[i][j] = s[j] == '0';
  }
  long long res = 0;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) {
      grid[i][j] = initgrid[i][j];
    }
  res += calc1(N, M);
  res += calc2(N, M);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) {
      grid[i][j] = initgrid[N - i - 1][j];
    }
  res += calc1(N, M);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) {
      grid[i][j] = initgrid[i][M - j - 1];
    }
  res += calc1(N, M);
  res += calc2(N, M);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) {
      grid[i][j] = initgrid[N - i - 1][M - j - 1];
    }
  res += calc1(N, M);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) {
      grid[j][i] = initgrid[i][j];
    }
  swap(N, M);
  res += calc2(N, M);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) {
      initgrid[i][j] = grid[i][j];
    }
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) {
      grid[i][j] = initgrid[i][M - j - 1];
    }
  res += calc2(N, M);
  cout << res << "\n";
  return 0;
}
