#include <bits/stdc++.h>
using namespace std;
int n, m, A[444][444], DP[444][444], D1[444][444], D2[444][444];
int get(int x1, int y1, int x2, int y2) {
  return (DP[x2][y2] - DP[x1 - 1][y2] - DP[x2][y1 - 1] + DP[x1 - 1][y1 - 1]);
}
int getd1(int x1, int y1, int x2, int y2) {
  return (D1[x2][y2] - D1[x1 - 1][y1 - 1]);
}
int getd2(int x1, int y1, int x2, int y2) {
  return (D2[x2][y2] - D2[x1 - 1][y1 + 1]);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%1d", &A[i][j]);
      A[i][j] = 1 - A[i][j];
      DP[i][j] = A[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    int sum = 0;
    for (int j = 1; j <= m; j++) {
      sum += DP[i][j];
      DP[i][j] = sum + DP[i - 1][j];
      D1[i][j] = D1[i - 1][j - 1] + A[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = m; j >= 1; j--) {
      D2[i][j] = A[i][j];
      D2[i][j] += D2[i - 1][j + 1];
    }
  }
  long long int ans = 0;
  int x1, y1, x2, y2;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (!A[i][j]) continue;
      int k = 1;
      x1 = i;
      y1 = j;
      while (1) {
        x2 = x1 + k;
        y2 = y1 + k;
        if (x2 > n || y2 > m || !A[x2][y2]) break;
        if (get(x1, y1, x1, y2) == y2 - y1 + 1 &&
            get(x1, y2, x2, y2) == x2 - x1 + 1)
          ans++;
        if (get(x1, y1, x2, y1) == x2 - x1 + 1 &&
            get(x2, y1, x2, y2) == y2 - y1 + 1)
          ans++;
        k++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = m; j >= 1; j--) {
      if (!A[i][j]) continue;
      int k = 1;
      x1 = i;
      y1 = j;
      while (1) {
        x2 = x1 + k;
        y2 = y1 - k;
        if (x2 > n || y2 < 1 || !A[x2][y2]) break;
        if (get(x1, y2, x1, y1) == y1 - y2 + 1 &&
            get(x1, y2, x2, y2) == x2 - x1 + 1)
          ans++;
        if (get(x1, y1, x2, y1) == x2 - x1 + 1 &&
            get(x2, y2, x2, y1) == y1 - y2 + 1)
          ans++;
        k++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (!A[i][j]) continue;
      for (int k = j; k <= m; k++) {
        int d = k - j;
        if (!A[i][k]) break;
        if (d % 2 || d == 0) continue;
        d /= 2;
        if (i + d <= n) {
          if (getd1(i, j, i + d, j + d) == d + 1 &&
              getd2(i, k, i + d, k - d) == d + 1) {
            ans++;
          }
        }
        if (i - d > 0) {
          if (getd2(i - d, j + d, i, j) == d + 1 &&
              getd1(i - d, k - d, i, k) == d + 1) {
            ans++;
          }
        }
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (!A[j][i]) continue;
      for (int k = j; k <= n; k++) {
        int d = k - j;
        if (!A[k][i]) break;
        if (d % 2 || d == 0) continue;
        d /= 2;
        if (i + d <= m) {
          if (getd1(j, i, j + d, i + d) == d + 1 &&
              getd2(j + d, i + d, k, i) == d + 1) {
            ans++;
          }
        }
        if (i - d > 0) {
          if (getd2(j, i, j + d, i - d) == d + 1 &&
              getd1(j + d, i - d, k, i) == d + 1) {
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
