#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double PI = acos(-1.0);
using namespace std;
char g[405][405];
int up[405][405], down[405][405];
int rt[405][405], lt[405][405];
int RU[405][405], RD[405][405];
int LU[405][405], LD[405][405];
int n, m;
int u(int i, int j) {
  if (~up[i][j]) return up[i][j];
  if (g[i][j] == '1') return 0;
  if (i)
    return up[i][j] = u(i - 1, j) + 1;
  else
    return up[i][j] = 1;
}
int d(int i, int j) {
  if (~down[i][j]) return down[i][j];
  if (g[i][j] == '1') return 0;
  if (i < n - 1)
    return down[i][j] = d(i + 1, j) + 1;
  else
    return down[i][j] = 1;
}
int l(int i, int j) {
  if (~lt[i][j]) return lt[i][j];
  if (g[i][j] == '1') return 0;
  if (j)
    return lt[i][j] = l(i, j - 1) + 1;
  else
    return lt[i][j] = 1;
}
int r(int i, int j) {
  if (~rt[i][j]) return rt[i][j];
  if (g[i][j] == '1') return 0;
  if (j < m - 1)
    return rt[i][j] = r(i, j + 1) + 1;
  else
    return rt[i][j] = 1;
}
int lu(int i, int j) {
  if (~LU[i][j]) return LU[i][j];
  if (g[i][j] == '1') return 0;
  if (i && j)
    return LU[i][j] = lu(i - 1, j - 1) + 1;
  else
    return LU[i][j] = 1;
}
int ru(int i, int j) {
  if (~RU[i][j]) return RU[i][j];
  if (g[i][j] == '1') return 0;
  if (i && j < m - 1)
    return RU[i][j] = ru(i - 1, j + 1) + 1;
  else
    return RU[i][j] = 1;
}
int ld(int i, int j) {
  if (~LD[i][j]) return LD[i][j];
  if (g[i][j] == '1') return 0;
  if (i < n - 1 && j)
    return LD[i][j] = ld(i + 1, j - 1) + 1;
  else
    return LD[i][j] = 1;
}
int rd(int i, int j) {
  if (~RD[i][j]) return RD[i][j];
  if (g[i][j] == '1') return 0;
  if (i < n - 1 && j < m - 1)
    return RD[i][j] = rd(i + 1, j + 1) + 1;
  else
    return RD[i][j] = 1;
}
int main(void) {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", g[i]);
  long long ans = 0;
  memset(up, -1, sizeof(up));
  memset(down, -1, sizeof(down));
  memset(lt, -1, sizeof(lt));
  memset(rt, -1, sizeof(rt));
  memset(RU, -1, sizeof(RU));
  memset(RD, -1, sizeof(RD));
  memset(LU, -1, sizeof(LU));
  memset(LD, -1, sizeof(LD));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (g[i][j] == '1') continue;
      for (int k = 2; k <= min(r(i, j), u(i, j)); k++) {
        int x = i - k + 1;
        if (rd(x, j) >= k) {
          ans++;
        }
      }
      for (int k = 2; k <= min(l(i, j), u(i, j)); k++) {
        int x = i - k + 1;
        if (ld(x, j) >= k) {
          ans++;
        }
      }
      for (int k = 2; k <= min(l(i, j), d(i, j)); k++) {
        int x = i + k - 1;
        if (lu(x, j) >= k) {
          ans++;
        }
      }
      for (int k = 2; k <= min(r(i, j), d(i, j)); k++) {
        int x = i + k - 1;
        if (ru(x, j) >= k) {
          ans++;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int a = 0; a < m; a++) {
      if (g[i][a] == '1') continue;
      for (int b = a + 2, l = 2; b < m; b += 2, l++) {
        if (g[i][b] == '1' || g[i][b - 1] == '1') break;
        if (ru(i, a) >= l && lu(i, b) >= l) {
          ans++;
        }
        if (rd(i, a) >= l && ld(i, b) >= l) {
          ans++;
        }
      }
    }
  }
  for (int i = 0; i < m; i++) {
    for (int a = 0; a < n; a++) {
      if (g[a][i] == '1') continue;
      for (int b = a + 2, l = 2; b < n; b += 2, l++) {
        if (g[b][i] == '1' || g[b - 1][i] == '1') break;
        if (rd(a, i) >= l && ru(b, i) >= l) {
          ans++;
        }
        if (ld(a, i) >= l && lu(b, i) >= l) {
          ans++;
        }
      }
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
