#include <bits/stdc++.h>
using namespace std;
const int maxN = 400 + 5;
int a[maxN][maxN];
int row[maxN][maxN];
int col[maxN][maxN];
int d1[maxN][maxN];
int d2[maxN][maxN];
inline int get(int r1, int c1, int r2, int c2) {
  if (c1 == c2) {
    if (r1 > r2) swap(r1, r2);
    return col[r2][c1] - col[r1 - 1][c1];
  }
  if (r1 == r2) {
    if (c1 > c2) swap(c1, c2);
    return row[r1][c2] - row[r1][c1 - 1];
  }
  if (r1 > r2) swap(r1, r2), swap(c1, c2);
  if (c1 < c2)
    return d1[r2][c2] - d1[r1 - 1][c1 - 1];
  else
    return d2[r2][c2] - d2[r1 - 1][c1 + 1];
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      a[i][j] = c - '0';
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      row[i][j] = row[i][j - 1] + a[i][j];
      col[i][j] = col[i - 1][j] + a[i][j];
      d1[i][j] = d1[i - 1][j - 1] + a[i][j];
    }
  for (int i = 1; i <= n; i++)
    for (int j = m; j > 0; j--) d2[i][j] = a[i][j] + d2[i - 1][j + 1];
  int ans = 0;
  for (int r = 1; r <= n; r++) {
    for (int i = 1; i <= m; i++) {
      if (a[r][i]) continue;
      ;
      for (int j = i + 1; j <= m; j++) {
        if (a[r][j] == 1) break;
        if ((j - i) % 2 == 0) {
          int k = (i + j) / 2;
          int q = (j - i) / 2;
          if (r - q >= 1 && get(r, j, r - q, k) + get(r, i, r - q, k) == 0)
            ans++;
          if (r + q <= n && get(r + q, k, r, j) + get(r + q, k, r, i) == 0)
            ans++;
        }
      }
    }
  }
  for (int r = 1; r <= n; r++) {
    for (int i = 1; i <= m; i++) {
      if (a[r][i]) continue;
      for (int j = i + 1; j <= m; j++) {
        if (a[r][j] == 1) break;
        int q = j - i;
        if (r - q >= 1 && get(r, i, r - q, i) + get(r, j, r - q, i) == 0) ans++;
        if (r + q <= n && get(r + q, i, r, i) + get(r + q, i, r, j) == 0) ans++;
        if (r - q >= 1 && get(r, j, r - q, j) + get(r, i, r - q, j) == 0) ans++;
        if (r + q <= n && get(r + q, j, r, j) + get(r + q, j, r, i) == 0) ans++;
      }
    }
  }
  for (int c = 1; c <= m; c++)
    for (int i = 1; i <= n; i++) {
      if (a[i][c]) continue;
      for (int j = i + 1; j <= n; j++) {
        if (a[j][c]) break;
        if ((j - i) % 2 == 0) {
          int k = (i + j) / 2;
          int q = (j - i) / 2;
          if (c - q >= 1 && get(j, c, k, c - q) + get(i, c, k, c - q) == 0)
            ans++;
          if (c + q <= m && get(k, c + q, j, c) + get(k, c + q, i, c) == 0)
            ans++;
        }
      }
    }
  cout << ans << endl;
  return 0;
}
