#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
const int N = 500;
int row[N][N], col[N][N], one[N][N], two[N][N];
char arr[N][N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      scanf(" %c", &arr[i][j]);
      row[i][j] = row[i - 1][j] + (arr[i][j] - '0');
      col[i][j] = col[i][j - 1] + (arr[i][j] - '0');
      one[i][j] = one[i - 1][j - 1] + (arr[i][j] - '0');
      two[i][j] = two[i - 1][j + 1] + (arr[i][j] - '0');
    }
  int ans = 0;
  for (int k = 1; k <= max(n, m); k++) {
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        ans += (i + k <= n and j + k <= m and col[i][j + k] == col[i][j - 1] and
                row[i + k][j] == row[i - 1][j] and
                two[i + k][j] == two[i - 1][j + k + 1]);
        ans += (i + k <= n and j - k >= 1 and col[i][j - k - 1] == col[i][j] and
                row[i + k][j] == row[i - 1][j] and
                one[i + k][j] == one[i - 1][j - k - 1]);
        ans += (i - k >= 1 and j - k >= 1 and col[i][j - k - 1] == col[i][j] and
                row[i - k - 1][j] == row[i][j] and
                two[i - k - 1][j + 1] == two[i][j - k]);
        ans += (i - k >= 1 and j + k <= m and col[i][j + k] == col[i][j - 1] and
                row[i - k - 1][j] == row[i][j] and
                one[i][j + k] == one[i - k - 1][j - 1]);
        if (k % 2 == 0) {
          ans += (j + k <= m and i - k / 2 >= 1 and
                  col[i][j + k] == col[i][j - 1] and
                  one[i][j + k] == one[i - k / 2 - 1][j + k / 2 - 1] and
                  two[i][j] == two[i - k / 2 - 1][j + k / 2 + 1]);
          ans += (j + k <= m and i + k / 2 <= n and
                  col[i][j + k] == col[i][j - 1] and
                  one[i + k / 2][j + k / 2] == one[i - 1][j - 1] and
                  two[i + k / 2][j + k / 2] == two[i - 1][j + k + 1]);
          ans += (j + k / 2 <= m and i + k <= n and
                  row[i + k][j] == row[i - 1][j] and
                  one[i + k / 2][j + k / 2] == one[i - 1][j - 1] and
                  two[i + k][j] == two[i + k / 2 - 1][j + k / 2 + 1]);
          ans += (j - k / 2 >= 1 and i + k <= n and
                  row[i + k][j] == row[i - 1][j] and
                  two[i + k / 2][j - k / 2] == two[i - 1][j + 1] and
                  one[i + k][j] == one[i + k / 2 - 1][j - k / 2 - 1]);
        }
      }
  }
  printf("%d\n", ans);
  return 0;
}
