#include <bits/stdc++.h>
using namespace std;
int sum1[403][403];
int sum2[403][403];
int sum3[803][403];
int sum4[803][403];
char s[403][403];
int n, m;
int main() {
  scanf("%d %d", &n, &m);
  int i, j, k;
  for (i = 0; i < n; i++) scanf("%s", s[i]);
  for (i = 0; i < n; i++) {
    sum1[i][0] = s[i][0] - '0';
    for (j = 1; s[i][j]; j++) sum1[i][j] = sum1[i][j - 1] + s[i][j] - '0';
  }
  for (j = 0; j < m; j++) {
    sum2[0][j] = s[0][j] - '0';
    for (i = 1; i < n; i++) sum2[i][j] = sum2[i - 1][j] + s[i][j] - '0';
  }
  int x, y;
  for (i = 0; i < n; i++) {
    x = 0;
    y = i;
    sum3[i][0] = s[i][0] - '0';
    x++;
    y--;
    while (y > -1 && x < m) {
      sum3[i][min(n - 1 - y, x)] =
          sum3[i][min(n - 1 - y, x) - 1] + s[y][x] - '0';
      y--;
      x++;
    }
  }
  for (j = 0; j < m; j++) {
    x = j;
    y = n - 1;
    sum3[n - 1 + j][0] = s[n - 1][j] - '0';
    x++;
    y--;
    while (y > -1 && x < m) {
      sum3[n - 1 + j][min(n - 1 - y, x)] =
          sum3[n - 1 + j][min(n - 1 - y, x) - 1] + s[y][x] - '0';
      y--;
      x++;
    }
  }
  for (i = n - 1; i > -1; i--) {
    y = i;
    x = 0;
    sum4[n - 1 - i][0] = s[i][0] - '0';
    x++;
    y++;
    while (x < m && y < n) {
      sum4[n - 1 - i][min(x, y)] =
          sum4[n - 1 - i][min(x, y) - 1] + s[y][x] - '0';
      y++;
      x++;
    }
  }
  for (j = 0; j < m; j++) {
    y = 0;
    x = j;
    sum4[n - 1 + j][0] = s[0][j] - '0';
    x++;
    y++;
    while (x < m && y < n) {
      sum4[n - 1 + j][min(x, y)] =
          sum4[n - 1 + j][min(x, y) - 1] + s[y][x] - '0';
      x++;
      y++;
    }
  }
  int ans = 0;
  bool ok11, ok12, ok13, ok21, ok22, ok23, ok31, ok32, ok33, ok41, ok42, ok43;
  int tem;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      for (k = 1; k <= max(n, m); k++) {
        ok11 = ok21 = ok31 = ok41 = false;
        ok12 = ok22 = ok32 = ok42 = false;
        ok13 = ok23 = ok33 = ok43 = false;
        if (i - k > -1) {
          tem = sum2[i][j];
          if (i - k > 0) tem -= sum2[i - k - 1][j];
          if (tem == 0) ok22 = ok12 = true;
        }
        if (j - k > -1) {
          tem = sum1[i][j];
          if (j - k > 0) tem -= sum1[i][j - k - 1];
          if (tem == 0) ok11 = ok31 = true;
        }
        if (j - k > -1 && i - k > -1) {
          tem = sum3[i + j - k][min(j, n - 1 - i + k)];
          if (min(j - k, n - 1 - i) > 0)
            tem -= sum3[i + j - k][min(j - k, n - 1 - i) - 1];
          if (tem == 0) ok13 = true;
        }
        if (j + k < m) {
          tem = sum1[i][j + k];
          if (j > 0) tem -= sum1[i][j - 1];
          if (tem == 0) ok21 = ok41 = true;
        }
        if (j + k < m && i - k > -1) {
          tem = sum4[n - 1 - i + j + k][min(i, j + k)];
          if (min(i - k, j) > 0)
            tem -= sum4[n - 1 - i + j + k][min(i - k, j) - 1];
          if (tem == 0) ok23 = true;
        }
        if (i + k < n) {
          tem = sum2[i + k][j];
          if (i > 0) tem -= sum2[i - 1][j];
          if (tem == 0) ok32 = ok42 = true;
        }
        if (j - k > -1 && i + k < n) {
          tem = sum4[n - 1 - i + j - k][min(i + k, j)];
          if (min(i, j - k) > 0)
            tem -= sum4[n - 1 - i + j - k][min(i + k, j) - k - 1];
          if (tem == 0) ok33 = true;
        }
        if (i + k < n && j + k < m) {
          tem = sum3[i + j + k][min(n - 1 - i, j + k)];
          if (min(n - 1 - i, j + k) - k > 0)
            tem -= sum3[i + j + k][min(n - 1 - i, j + k) - k - 1];
          if (tem == 0) ok43 = true;
        }
        ans += (ok11 & ok12 & ok13);
        ans += (ok21 & ok22 & ok23);
        ans += (ok31 & ok32 & ok33);
        ans += (ok41 & ok42 & ok43);
        ans += (ok13 & ok12 & ok32 & ok33);
        ans += (ok13 & ok23 & ok21 & ok11);
        ans += (ok23 & ok43 & ok42 & ok22);
        ans += (ok31 & ok41 & ok43 & ok33);
      }
    }
  printf("%d\n", ans);
  return 0;
}
