#include <bits/stdc++.h>
struct Node {
  int d[10];
};
Node a[401][401];
char p[401][401];
int main() {
  int i, j, n, m, res;
  while (scanf("%d%d", &n, &m) != EOF) {
    res = 0;
    for (i = 0; i < n; i++) scanf("%s", p[i]);
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (p[i][j] == '0') {
          if (j == 0 || p[i][j - 1] == '1')
            a[i][j].d[0] = 0;
          else
            a[i][j].d[0] = a[i][j - 1].d[0] + 1;
          if (j == 0 || i == 0 || p[i - 1][j - 1] == '1')
            a[i][j].d[1] = 0;
          else
            a[i][j].d[1] = a[i - 1][j - 1].d[1] + 1;
          if (i == 0 || p[i - 1][j] == '1')
            a[i][j].d[2] = 0;
          else
            a[i][j].d[2] = a[i - 1][j].d[2] + 1;
        } else {
          for (int d = 0; d < 8; d++) a[i][j].d[d] = 0;
        }
      }
      for (j = m - 1; j >= 0; j--) {
        if (p[i][j] == '0') {
          if (j == m - 1 || i == 0 || p[i - 1][j + 1] == '1')
            a[i][j].d[3] = 0;
          else
            a[i][j].d[3] = a[i - 1][j + 1].d[3] + 1;
          if (j == m - 1 || p[i][j + 1] == '1')
            a[i][j].d[4] = 0;
          else
            a[i][j].d[4] = a[i][j + 1].d[4] + 1;
        } else {
          for (int d = 0; d < 8; d++) a[i][j].d[d] = 0;
        }
      }
    }
    for (i = n - 1; i >= 0; i--) {
      for (j = m - 1; j >= 0; j--) {
        if (p[i][j] == '0') {
          if (j == m - 1 || i == n - 1 || p[i + 1][j + 1] == '1')
            a[i][j].d[5] = 0;
          else
            a[i][j].d[5] = a[i + 1][j + 1].d[5] + 1;
          if (i == n - 1 || p[i + 1][j] == '1')
            a[i][j].d[6] = 0;
          else
            a[i][j].d[6] = a[i + 1][j].d[6] + 1;
        } else {
          for (int d = 0; d < 8; d++) a[i][j].d[d] = 0;
        }
      }
      for (j = 0; j < m; j++) {
        if (p[i][j] == '0') {
          if (j == 0 || i == n - 1 || p[i + 1][j - 1] == '1')
            a[i][j].d[7] = 0;
          else
            a[i][j].d[7] = a[i + 1][j - 1].d[7] + 1;
        } else {
          for (int d = 0; d < 8; d++) a[i][j].d[d] = 0;
        }
      }
    }
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (p[i][j] == '0') {
          for (int d = 0; d < 8; d++) {
            int r = a[i][j].d[d] < a[i][j].d[(d + 2) % 8]
                        ? a[i][j].d[d]
                        : a[i][j].d[(d + 2) % 8];
            for (int l = 1; l <= r; l++) {
              if (d == 0) {
                if (a[i][j - l].d[3] >= l) res++;
              }
              if (d == 1) {
                if (a[i - l][j - l].d[4] >= 2 * l) res++;
              }
              if (d == 2) {
                if (a[i - l][j].d[5] >= l) res++;
              }
              if (d == 3) {
                if (a[i - l][j + l].d[6] >= 2 * l) res++;
              }
              if (d == 4) {
                if (a[i][j + l].d[7] >= l) res++;
              }
              if (d == 5) {
                if (a[i + l][j + l].d[0] >= 2 * l) res++;
              }
              if (d == 6) {
                if (a[i + l][j].d[1] >= l) res++;
              }
              if (d == 7) {
                if (a[i + l][j - l].d[2] >= 2 * l) res++;
              }
            }
          }
        }
      }
    }
    printf("%d\n", res);
  }
  return 0;
}
