#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int MAX(int a, int b) { return (a > b) ? a : b; }
int MIN(int a, int b) { return (a < b) ? a : b; }
int ABS(int x) { return (x > 0) ? x : -x; }
int sum[1000][1000][3], n, m, sum2[1000][1000][3];
char mapa[1000][1000];
bool out(int r, int c) {
  return (r < 0 || r >= n || c < 0 || c >= m || mapa[r][c] == '1');
}
int getSum(int r1, int c1, int r2, int c2, int idx) {
  if (idx == 0) {
    if (r1 == 0)
      return sum[r2 + c2][r2][0];
    else
      return sum[r2 + c2][r2][0] - sum[r1 + c1][r1 - 1][0];
  } else {
    if (c1 == 0)
      return sum[c2 - r2 + n][c2][1];
    else
      return sum[c2 - r2 + n][c2][1] - sum[c1 - r1 + n][c1 - 1][1];
  }
}
int getSum2(int l, int r, int m, int idx) {
  if (l == 0)
    return sum2[m][r][idx];
  else
    return sum2[m][r][idx] - sum2[m][l - 1][idx];
}
int check(int r, int c, int len) {
  int ansa = 0;
  if (!out(r - len, c) && !out(r, c + len) &&
      getSum(r - len, c, r, c + len, 1) == 0 &&
      getSum2(r - len, r, c, 0) == 0 && getSum2(c, c + len, r, 1) == 0) {
    ansa++;
  }
  if (!out(r, c + len) && !out(r + len, c) &&
      getSum(r, c + len, r + len, c, 0) == 0 &&
      getSum2(r + len, r, c, 0) == 0 && getSum2(c, c + len, r, 1) == 0) {
    ansa++;
  }
  if (!out(r + len, c) && !out(r, c - len) &&
      getSum(r, c - len, r + len, c, 1) == 0 &&
      getSum2(r + len, r, c, 0) == 0 && getSum2(c, c - len, r, 1) == 0) {
    ansa++;
  }
  if (!out(r, c - len) && !out(r - len, c) &&
      getSum(r - len, c, r, c - len, 0) == 0 &&
      getSum2(r - len, r, c, 0) == 0 && getSum2(c, c - len, r, 1) == 0) {
    ansa++;
  }
  if (!out(r - len, c - len) && !out(r - len, c + len) &&
      getSum2(c - len, c + len, r - len, 1) == 0 &&
      getSum(r - len, c - len, r, c, 1) == 0 &&
      getSum(r - len, c + len, r, c, 0) == 0) {
    ansa++;
  }
  if (!out(r - len, c + len) && !out(r + len, c + len) &&
      getSum2(r - len, r + len, c + len, 0) == 0 &&
      getSum(r, c, r + len, c + len, 1) == 0 &&
      getSum(r - len, c + len, r, c, 0) == 0) {
    ansa++;
  }
  if (!out(r + len, c + len) && !out(r + len, c - len) &&
      getSum2(c - len, c + len, r + len, 1) == 0 &&
      getSum(r, c, r + len, c + len, 1) == 0 &&
      getSum(r, c, r + len, c - len, 0) == 0) {
    ansa++;
  }
  if (!out(r + len, c - len) && !out(r - len, c - len) &&
      getSum2(r - len, r + len, c - len, 0) == 0 &&
      getSum(r - len, c - len, r, c, 1) == 0 &&
      getSum(r, c, r + len, c - len, 0) == 0) {
    ansa++;
  }
  return ansa;
}
int main() {
  scanf("%d %d", &n, &m);
  for (long long int i = 0; i < (long long int)n; i++) scanf("%s", mapa[i]);
  for (long long int i = 0; i < (long long int)n; i++)
    for (long long int j = 0; j < (long long int)m; j++) {
      int ne = mapa[i][j] - '0';
      sum[i + j][i][0] += ne;
      sum[j - i + n][j][1] += ne;
      sum2[i][j][1] += ne;
      sum2[j][i][0] += ne;
    }
  for (long long int i = 0; i < (long long int)n; i++)
    for (long long int j = 0; j < (long long int)m; j++) {
      if (i > 0) sum[i + j][i][0] += sum[i + j][i - 1][0];
      if (j > 0) sum[j - i + n][j][1] += sum[j - i + n][j - 1][1];
      if (j > 0) sum2[i][j][1] += sum2[i][j - 1][1];
      if (i > 0) sum2[j][i][0] += sum2[j][i - 1][0];
    }
  int ans = 0;
  for (long long int i = 0; i < (long long int)n; i++)
    for (long long int j = 0; j < (long long int)m; j++) {
      if (mapa[i][j] == '1') continue;
      for (int k = 1; k < MAX(n, m); k++) {
        int temp = check(i, j, k);
        ans += temp;
      }
    }
  printf("%d\n", ans);
}
