#include <bits/stdc++.h>
char s[510][510];
int a[510][510][8], b[510][510][8];
int dx[4] = {0, 0, 1, 1}, dy[4] = {0, 1, 0, 1};
int n, m;
int len(int k) { return (1 << k); }
int main() {
  int i, j, h, k, x, y, num;
  while (scanf("%d %d", &n, &m) != EOF) {
    for (i = 0; i < n; i++) scanf("%s", s[i]);
    num = 0;
    for (i = 0; i < n; i++)
      for (j = 0; j < m; j++) a[i][j][0] = (s[i][j] == '*' ? 1 : 0);
    for (k = 1; len(k) <= m && len(k) <= n; k++) {
      for (i = 0; i < n - len(k) + 1; i++) {
        for (j = 0; j < m - len(k) + 1; j++) {
          a[i][j][k] = b[i][j][k] = 0;
          for (h = 0; h < 4; h++) {
            a[i][j][k] +=
                a[i + dx[h] * len(k - 1)][j + dy[h] * len(k - 1)][k - 1];
            if (a[i + dx[h] * len(k - 1)][j + dy[h] * len(k - 1)][k - 1] ==
                len(2 * (k - 1)))
              b[i][j][k] |= len(h);
          }
          if (k > 1) {
            for (h = 0; h < 4; h++) {
              if (b[i][j][k] & len(h)) continue;
              if (b[i][j][k] !=
                  b[i + dx[h] * len(k - 1)][j + dy[h] * len(k - 1)][k - 1]) {
                b[i][j][k] = -1;
                break;
              }
            }
            if (b[i][j][k] != -1) num++;
          }
        }
      }
    }
    printf("%d\n", num);
  }
  return 0;
}
