#include <bits/stdc++.h>
using namespace std;
const int N = 405;
int n, m, k;
int D[N][N], xD[2 * N][N], yD[4 * N][N], L[N][N];
char a[N][N];
int res[N][N];
int kNgang(int u, int v, int t) { return (L[u][v] - L[u][t - 1] == 0); }
int kDoc(int x, int y, int t) { return (D[x][y] - D[t - 1][y] == 0); }
int kCheo(int p, int v, int t) { return (xD[p][v] - xD[p][t - 1] == 0); }
int kXien(int p, int v, int t) { return (yD[p][v] - yD[p][t - 1] == 0); }
int main() {
  cin >> n >> m;
  k = m;
  for (int i = 1; i <= n; i++) {
    char c = getchar();
    for (int j = 1; j <= m; j++) {
      a[i][j] = getchar();
      if (a[i][j] == '1') {
        D[i][j] = D[i - 1][j] + 1;
        L[i][j] = L[i][j - 1] + 1;
      } else {
        D[i][j] = D[i - 1][j];
        L[i][j] = L[i][j - 1];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == '1') {
        xD[i + j][i] = xD[i + j][i - 1] + 1;
        yD[i - j + k][i] = yD[i - j + k][i - 1] + 1;
      } else {
        xD[i + j][i] = xD[i + j][i - 1];
        yD[i - j + k][i] = yD[i - j + k][i - 1];
      }
    }
  }
  int kt = 0;
  for (int i = 1; i <= n; i++) res[i][1] = 0;
  for (int i = 1; i <= m; i++) res[1][i] = 0;
  for (int i = 2; i <= n; i++)
    for (int j = 2; j <= m; j++) {
      res[i][j] = res[i - 1][j] + res[i][j - 1] - res[i - 1][j - 1];
      for (int t = 1, u = max(i, j) - 1; t <= u; t++) {
        if (i > t && j > t && kDoc(i, j, i - t) && kNgang(i, j, j - t) &&
            kCheo(i + j - t, i, i - t))
          res[i][j]++;
        if (i > t && j > t && kDoc(i, j, i - t) && kNgang(i - t, j, j - t) &&
            kXien(i - j + k, i, i - t))
          res[i][j]++;
        if (i > t && j > t && kNgang(i, j, j - t) && kDoc(i, j - t, i - t) &&
            kXien(i - j + k, i, i - t))
          res[i][j]++;
        if (t % 2 == 0) {
          if (i > t / 2 && j > t && kNgang(i, j, j - t) &&
              kXien(i - j + k, i, i - t / 2) && kCheo(i + j - t, i, i - t / 2))
            res[i][j]++;
          if (i > t && j > t / 2 && kDoc(i, j, i - t) &&
              kXien(i - j + k, i, i - t / 2) &&
              kCheo(i + j - t, i - t / 2, i - t))
            res[i][j]++;
        }
        if (i > t && j > t && kDoc(i, j - t, i - t) &&
            kNgang(i - t, j, j - t) && kCheo(i + j - t, i, i - t))
          res[i][j]++;
        if (i > t * 2 && j > t && kDoc(i, j - t, i - t * 2) &&
            kCheo(i + j - t, i, i - t) &&
            kXien(i - j + k - t, i - t, i - 2 * t))
          res[i][j]++;
        if (j > t * 2 && i > t && kCheo(i + j - t, i, i - t) &&
            kNgang(i - t, j, j - 2 * t) && kXien(i - j + k + t, i, i - t))
          res[i][j]++;
      }
    }
  cout << res[n][m];
}
