#include <bits/stdc++.h>
using namespace std;
int n, m;
char c[411][411];
int tot, d1[811][411], d2[1111][411], row[411][411], col[411][411];
inline void precalc() {
  int i = 1, j = 1;
  while (i <= n) {
    for (int i1 = i, j1 = j, p = 1; i1 <= n && j1 >= 1; i1++, j1--, p++) {
      d1[i1 + j1][p] += d1[i1 + j1][p - 1];
      if (c[i1][j1] == '1') d1[i1 + j1][p]++;
    }
    if (j == m)
      i++;
    else
      j++;
  }
  i = 1, j = m;
  while (i <= n) {
    for (int i1 = i, j1 = j, p = 1; i1 <= n && j1 <= m; i1++, j1++, p++) {
      d2[i1 - j1 + 500][p] += d2[i1 - j1 + 500][p - 1];
      if (c[i1][j1] == '1') d2[i1 - j1 + 500][p]++;
    }
    if (j == 1)
      i++;
    else
      j--;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      col[i][j] += col[i][j - 1];
      if (c[i][j] == '1') col[i][j]++;
    }
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) {
      row[i][j] += row[i][j - 1];
      if (c[j][i] == '1') row[i][j]++;
    }
}
inline bool check(int i, int j, int i1, int j1) {
  if (i1 < 1 || j1 < 1 || i1 > n || j1 > m) return 0;
  int pi = min(i1, j), pj = min(i, j1);
  if (i1 - j == i - j1 &&
      (d2[i1 - j + 500][pi] - d2[i - j1 + 500][pj - 1] > 0 ||
       d2[i - j1 + 500][pj] - d2[i1 - j + 500][pi - 1] > 0))
    return 0;
  pi = min(m - j, i1 - 1) + 1, pj = min(m - j1, i - 1) + 1;
  if (i1 + j == i + j1 && (d1[i1 + j][pi] - d1[i + j1][pj - 1] > 0 ||
                           d1[i + j1][pj] - d1[i1 + j][pi - 1] > 0))
    return 0;
  return 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf(" %c", &c[i][j]);
  precalc();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (c[i][j] == '1') continue;
      for (int len = 1; len <= 400; len++) {
        int i1 = i - len, i2 = i + len, j1 = j - len, j2 = j + len;
        if (check(i, j, i1, j1) && row[j][i] - row[j][i1 - 1] < 1 &&
            col[i][j] - col[i][j1 - 1] < 1)
          tot++;
        if (check(i, j, i1, j2) && row[j][i] - row[j][i1 - 1] < 1 &&
            col[i][j2] - col[i][j - 1] < 1)
          tot++;
        if (check(i, j, i2, j1) && row[j][i2] - row[j][i - 1] < 1 &&
            col[i][j] - col[i][j1 - 1] < 1)
          tot++;
        if (check(i, j, i2, j2) && row[j][i2] - row[j][i - 1] < 1 &&
            col[i][j2] - col[i][j - 1] < 1)
          tot++;
        if (check(i, j, i1, j1) && check(i, j, i1, j2) &&
            col[i][j2] - col[i][j1 - 1] < 1)
          tot++;
        if (check(i, j, i2, j1) && check(i, j, i2, j2) &&
            col[i][j2] - col[i][j1 - 1] < 1)
          tot++;
        if (check(i, j, i1, j2) && check(i, j, i2, j2) &&
            row[j][i2] - row[j][i1 - 1] < 1)
          tot++;
        if (check(i, j, i1, j1) && check(i, j, i2, j1) &&
            row[j][i2] - row[j][i1 - 1] < 1)
          tot++;
      }
    }
  printf("%d", tot);
  return 0;
}
