#include <bits/stdc++.h>
using namespace std;
int main() {
  int row, col;
  cin >> row >> col;
  char table[405][405];
  for (int i = 0; i < row; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < col; j++) table[i][j] = s[j] - '0';
  }
  int dis1[405][405], dis2[405][405], dis3[405][405], dis4[405][405];
  memset(dis1, 0, sizeof(dis1));
  memset(dis2, 0, sizeof(dis2));
  memset(dis3, 0, sizeof(dis3));
  memset(dis4, 0, sizeof(dis4));
  for (int i = 0; i < row; i++)
    for (int j = col - 1; j >= 0; j--)
      if (!table[i][j]) dis1[i][j] = 1 + dis1[i][j + 1];
  for (int i = row - 1; i >= 0; i--)
    for (int j = col - 1; j >= 0; j--)
      if (!table[i][j]) {
        dis2[i][j] = 1 + dis2[i + 1][j + 1];
      }
  for (int j = 0; j < col; j++)
    for (int i = row - 1; i >= 0; i--)
      if (!table[i][j]) dis3[i][j] = 1 + dis3[i + 1][j];
  for (int i = row - 1; i >= 0; i--)
    for (int j = 0; j < col; j++)
      if (!table[i][j]) {
        dis4[i][j] = 1;
        if (j - 1 >= 0) dis4[i][j] += dis4[i + 1][j - 1];
      }
  int res = 0;
  for (int i = 0; i < row; i++)
    for (int j = 0; j < col; j++)
      if (!table[i][j]) {
        for (int d = 2; d <= dis1[i][j]; d++) {
          if (dis3[i][j + d - 1] >= d && dis2[i][j] >= d) res++;
          if (d % 2 == 1 && dis4[i][j + d - 1] >= (d + 1) / 2 &&
              dis2[i][j] >= (d + 1) / 2)
            res++;
          if (dis4[i][j + d - 1] >= d && dis3[i][j] >= d) res++;
        }
        for (int d = 2; d <= dis2[i][j]; d++) {
          if (dis3[i][j] >= d && dis1[i + d - 1][j] >= d) res++;
          if (dis3[i][j] >= 2 * d - 1 && dis4[i + d - 1][j + d - 1] >= d) res++;
          if (dis4[i][j] >= d && dis1[i + d - 1][j - d + 1] >= 2 * d - 1) res++;
        }
        for (int d = 2; d <= dis3[i][j]; d++) {
          if (dis4[i][j] >= d && dis1[i + d - 1][j - d + 1] >= d) res++;
          if (d % 2 == 1 && dis4[i][j] >= (d + 1) / 2 &&
              dis2[i + d / 2][j - d / 2] >= (d + 1) / 2)
            res++;
        }
      }
  cout << res;
  return 0;
}
