#include <bits/stdc++.h>
using namespace std;
const int N = 510;
int n, m;
char s[N][N];
bool a[N][N], b[N][N];
void output(int a[N][N], int n, int m) {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) printf("%d%c", a[i][j], " \n"[j == m - 1]);
  }
  puts("");
}
long long getcnt(bool a[N][N], int n, int m) {
  static int right[N][N], rd[N][N], ld[N][N], down[N][N];
  memset(right, 0, sizeof(right));
  memset(rd, 0, sizeof(rd));
  memset(ld, 0, sizeof(ld));
  memset(down, 0, sizeof(down));
  for (int i = 0; i < n; ++i) {
    for (int j = m - 1; j >= 0; --j) {
      right[i][j] = a[i][j] ? 0 : right[i][j + 1] + 1;
    }
  }
  for (int j = 0; j < m; ++j) {
    for (int i = n - 1; i >= 0; --i) {
      down[i][j] = a[i][j] ? 0 : down[i + 1][j] + 1;
    }
  }
  for (int i = n - 1; i >= 0; --i) {
    for (int j = m - 1; j >= 0; --j) {
      rd[i][j] = a[i][j] ? 0 : rd[i + 1][j + 1] + 1;
    }
  }
  for (int i = n - 1; i >= 0; --i) {
    ld[i][0] = a[i][0] ? 0 : 1;
    for (int j = 1; j < m; ++j) {
      ld[i][j] = a[i][j] ? 0 : ld[i + 1][j - 1] + 1;
    }
  }
  long long ret = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      for (int k = 1; k < min(rd[i][j], down[i][j]); ++k) {
        int ni = k + i;
        if (right[ni][j] >= k) {
          ++ret;
        }
      }
      for (int k = 1; k < min(rd[i][j], ld[i][j]); ++k) {
        int ni = i + k;
        int nj = j - k;
        if (right[ni][nj] >= 2 * k + 1) {
          ++ret;
        }
      }
    }
  }
  return ret;
}
void rotat(bool a[N][N], bool b[N][N], int n, int m) {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      b[j][n - i - 1] = a[i][j];
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%s", s + i);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) a[i][j] = s[i][j] == '1';
  long long ans = 0;
  ans += getcnt(a, n, m);
  rotat(a, b, n, m);
  ans += getcnt(b, m, n);
  rotat(b, a, m, n);
  ans += getcnt(a, n, m);
  rotat(a, b, n, m);
  ans += getcnt(b, m, n);
  printf("%lld\n", ans);
  return 0;
}
