#include <bits/stdc++.h>
using namespace std;
struct info {
  int d[405][405];
  void show() {
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 5; j++) printf("%d ", d[i][j]);
      printf("\n");
    }
  }
};
info U, D, L, R, LU, RU, LD, RD;
char str[405][405];
int n, m;
void getwhat(info& T, int x, int y, int dx, int dy) {
  T.d[x][y] = (str[x][y] == '0' ? 1 : 0);
  for (x += dx, y += dy; x >= 0 && y >= 0 && x < n && y < m; x += dx, y += dy) {
    if (str[x][y] == '0')
      T.d[x][y] = T.d[x - dx][y - dy] + 1;
    else
      T.d[x][y] = 0;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= n; i++) {
    scanf("%s", str[i]);
  }
  for (int j = 0; j < m; j++) {
    getwhat(U, 0, j, 1, 0);
    getwhat(D, n - 1, j, -1, 0);
    getwhat(LU, 0, j, 1, 1);
    getwhat(RU, 0, j, 1, -1);
    getwhat(LD, n - 1, j, -1, 1);
    getwhat(RD, n - 1, j, -1, -1);
  }
  for (int i = 0; i < n; i++) {
    getwhat(L, i, 0, 0, 1);
    getwhat(R, i, m - 1, 0, -1);
    getwhat(LU, i, 0, 1, 1);
    getwhat(RU, i, m - 1, 1, -1);
    getwhat(LD, i, 0, -1, 1);
    getwhat(RD, i, m - 1, -1, -1);
  }
  int ans = 0;
  int dd;
  for (int x = 0; x < n; x++) {
    for (int i = 0; x + i < n && i < m; i++) {
      if (str[x + i][0 + i] != '0') continue;
      for (int j = i + 1; x + j < n && j < m; j++) {
        if (str[x + j][j] != '0') break;
        dd = j - i + 1;
        if (R.d[x + i][i] >= dd && U.d[x + j][j] >= dd) ans++;
        if (L.d[x + j][j] >= dd && D.d[x + i][i] >= dd) ans++;
      }
    }
  }
  for (int y = 1; y < m; y++) {
    for (int i = 0; i < n && y + i < m; i++) {
      if (str[i][y + i] != '0') continue;
      for (int j = i + 1; j < n && y + j < m; j++) {
        if (str[j][y + j] != '0') break;
        dd = j - i + 1;
        if (R.d[i][y + i] >= dd && U.d[j][j + y] >= dd) ans++;
        if (L.d[j][j + y] >= dd && D.d[i][y + i] >= dd) ans++;
      }
    }
  }
  for (int y = 0; y < m; y++) {
    for (int i = 0; i < n && y - i >= 0; i++) {
      if (str[i][y - i] != '0') continue;
      for (int j = i + 1; j < n && y - j >= 0; j++) {
        if (str[j][y - j] != '0') break;
        dd = j - i + 1;
        if (L.d[i][y - i] >= dd && U.d[j][y - j] >= dd) ans++;
        if (R.d[j][y - j] >= dd && D.d[i][y - i] >= dd) ans++;
      }
    }
  }
  for (int x = 1; x < n; x++) {
    for (int i = 0; x + i < n && m - 1 - i >= 0; i++) {
      if (str[x + i][m - 1 - i] != '0') continue;
      for (int j = i + 1; x + j < n && m - 1 - j >= 0; j++) {
        if (str[x + j][m - 1 - j] != '0') break;
        dd = j - i + 1;
        if (L.d[x + i][m - 1 - i] >= dd && U.d[x + j][m - 1 - j] >= dd) ans++;
        if (R.d[x + j][m - 1 - j] >= dd && D.d[x + i][m - 1 - i] >= dd) ans++;
      }
    }
  }
  for (int y = 0; y < m; y++) {
    for (int i = 0; i < n; i++) {
      if (str[i][y] != '0') continue;
      for (int j = i + 2; j < n; j += 2) {
        dd = j - i + 1;
        if (D.d[i][y] < dd) break;
        dd = dd / 2 + 1;
        if (LD.d[i][y] >= dd && LU.d[j][y] >= dd) ans++;
        if (RD.d[i][y] >= dd && RU.d[j][y] >= dd) ans++;
      }
    }
  }
  for (int x = 0; x < n; x++) {
    for (int i = 0; i < m; i++) {
      if (str[x][i] != '0') continue;
      for (int j = i + 2; j < m; j += 2) {
        dd = j - i + 1;
        if (R.d[x][i] < dd) break;
        dd = dd / 2 + 1;
        if (RU.d[x][i] >= dd && LU.d[x][j] >= dd) ans++;
        if (RD.d[x][i] >= dd && LD.d[x][j] >= dd) ans++;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
