#include <bits/stdc++.h>
using namespace std;
char mp[444][444];
int dx1[126] = {0, -1, -1, -1, -1, -1, 0,  -1, 0, 1, 1, 1,
                1, 1,  0,  1,  -1, -1, -1, 1,  1, 1, 1, -1};
int dy1[126] = {-1, -1, 0,  -1, 0,  1, 1, 1, 1, 1,  0,  1,
                0,  -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1};
int sum[444][444];
bool check(int x1, int y1, int x2, int y2) {
  if (x1 > x2) swap(x1, x2);
  if (y1 > y2) swap(y1, y2);
  int res1 = 0, res2 = 0, res3 = 0, res4 = 0;
  if (x1 > 0 && y1 > 0) res1 = sum[x1 - 1][y1 - 1];
  if (x1 > 0) res2 = sum[x1 - 1][y2];
  if (y1 > 0) res3 = sum[x2][y1 - 1];
  res4 = sum[x2][y2];
  return res4 - res3 - res2 + res1;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", mp[i]);
  }
  sum[0][0] = (mp[0][0] == '1');
  for (int i = 1; i < n; i++) sum[i][0] = sum[i - 1][0] + (mp[i][0] == '1');
  for (int i = 1; i < m; i++) sum[0][i] = sum[0][i - 1] + (mp[0][i] == '1');
  for (int i = 1; i < n; i++)
    for (int j = 1; j < m; j++)
      sum[i][j] =
          sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + (mp[i][j] == '1');
  int cnt = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (mp[i][j] == '0') {
        for (int k = 0; k < 12; k++) {
          int nx1 = i, ny1 = j;
          int nx2 = i, ny2 = j;
          for (int l = 0;; l++) {
            nx1 += dx1[k * 2];
            ny1 += dy1[k * 2];
            nx2 += dx1[k * 2 + 1];
            ny2 += dy1[k * 2 + 1];
            if (nx1 < 0 || nx1 >= n || ny1 < 0 || ny1 >= m) break;
            if (nx2 < 0 || nx2 >= n || ny2 < 0 || ny2 >= m) break;
            if (mp[nx1][ny1] == '1' || mp[nx2][ny2] == '1') break;
            if (check(nx1, ny1, nx2, ny2) == 0) {
              cnt++;
              if (k >= 8) cnt++;
            }
          }
        }
      }
  printf("%d\n", cnt / 2);
}
