#include <bits/stdc++.h>
using namespace std;
int n, m;
int mp[500][500];
int rSum[500][500], cSum[500][500];
int dSumF[500][500], dSumB[500][500];
int blacks(int r1, int c1, int r2, int c2) {
  int ans = 1;
  if (r1 == r2 && c1 == c2) {
    ans = 1;
  } else if (r1 == r2) {
    if (c2 > c1) {
      ans = rSum[r1][c2] - rSum[r1][c1 - 1];
    } else {
      ans = rSum[r1][c1] - rSum[r1][c2 - 1];
    }
  } else if (c1 == c2) {
    if (r2 > r1) {
      ans = cSum[r2][c1] - cSum[r1 - 1][c1];
    } else {
      ans = cSum[r1][c1] - cSum[r2 - 1][c1];
    }
  } else if (abs(r1 - r2) == abs(c1 - c2)) {
    if (r1 < r2) {
      if (c1 < c2) {
        ans = dSumB[r2][c2] - dSumB[r1 - 1][c1 - 1];
      } else {
        ans = dSumF[r2][c2] - dSumF[r1 - 1][c1 + 1];
      }
    } else {
      if (c2 < c1) {
        ans = dSumB[r1][c1] - dSumB[r2 - 1][c2 - 1];
      } else {
        ans = dSumF[r1][c1] - dSumF[r2 - 1][c2 + 1];
      }
    }
  } else
    ans = 1;
  return ans;
}
int valid(int r1, int c1, int r2, int c2, int r3, int c3) {
  return !(blacks(r1, c1, r2, c2) || blacks(r1, c1, r3, c3) ||
           blacks(r2, c2, r3, c3));
}
int main() {
  scanf("%d %d\n", &n, &m);
  int i, j, k;
  char c;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      scanf("%c", &c);
      mp[i][j] = c - '0';
    }
    scanf("\n");
  }
  for (i = 0; i <= n + 1; i++) {
    for (j = 0; j <= m + 1; j++) {
      rSum[i][j] = 0;
      cSum[i][j] = 0;
      dSumB[i][j] = 0;
      dSumF[i][j] = 0;
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      rSum[i][j] = rSum[i][j - 1] + mp[i][j];
      cSum[i][j] = cSum[i - 1][j] + mp[i][j];
      dSumF[i][j] = dSumF[i - 1][j + 1] + mp[i][j];
      dSumB[i][j] = dSumB[i - 1][j - 1] + mp[i][j];
    }
  }
  int ans = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      for (k = 1; j + k <= m && i - k > 0; k++) {
        ans += valid(i, j, i, j + k, i - k, j);
      }
      for (k = 1; j - k > 0 && i - k > 0; k++) {
        ans += valid(i, j, i, j - k, i - k, j);
      }
      for (k = 1; j + k <= m && i + k <= n; k++) {
        ans += valid(i, j, i, j + k, i + k, j);
      }
      for (k = 1; j - k > 0 && i + k <= n; k++) {
        ans += valid(i, j, i, j - k, i + k, j);
      }
      k = 1;
      while (i - k > 0 && j + k <= m && j - k > 0) {
        ans += valid(i, j, i - k, j + k, i - k, j - k);
        k++;
      }
      k = 1;
      while (i + k <= n && j + k <= m && j - k > 0) {
        ans += valid(i, j, i + k, j + k, i + k, j - k);
        k++;
      }
      k = 1;
      while (j - k > 0 && i + k <= n && i - k > 0) {
        ans += valid(i, j, i + k, j - k, i - k, j - k);
        k++;
      }
      k = 1;
      while (j + k <= m && i + k <= n && i - k > 0) {
        ans += valid(i, j, i + k, j + k, i - k, j + k);
        k++;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
