#include <bits/stdc++.h>
const int maxm = 510;
const int maxn = 510;
char a[maxm + 1][maxn + 1];
bool black[maxm + 1][maxn + 1][9];
bool f[maxm + 1][maxn + 1][9];
int m, n, result = 0;
void init() {
  int i, j;
  scanf("%d%d", &m, &n);
  for (i = 1; i <= m; ++i) {
    scanf("%s", a[i] + 1);
  }
}
void work() {
  int i, j, k, x, y, p, pat;
  for (i = 1; i <= m; ++i)
    for (j = 1; j <= n; ++j)
      if (a[i][j] == '*')
        black[i][j][0] = 1;
      else
        black[i][j][0] = 0;
  for (k = 1; k <= 8; ++k) {
    for (i = 1; i <= m; ++i)
      for (j = 1; j <= n; ++j)
        if ((i + (1 << k) - 1 <= m) && (j + (1 << k) - 1 <= n)) {
          black[i][j][k] =
              (black[i][j][k - 1] & black[i][j + (1 << (k - 1))][k - 1] &
               black[i + (1 << (k - 1))][j][k - 1] &
               black[i + (1 << (k - 1))][j + (1 << (k - 1))][k - 1]);
        } else
          black[i][j][k] = 0;
  }
  for (pat = 0; pat < 16; ++pat) {
    for (k = 1; k <= 8; ++k) {
      for (i = 1; i <= m; ++i)
        for (j = 1; j <= n; ++j)
          if ((i + (1 << k) - 1 <= m) && (j + (1 << k) - 1 <= n)) {
            f[i][j][k] = true;
            p = 0;
            for (x = 0; x <= (1 << (k - 1)); x += (1 << (k - 1)))
              for (y = 0; y <= (1 << (k - 1)); y += (1 << (k - 1))) {
                if (k == 1) {
                  if ((1 << p) & pat)
                    f[i][j][k] = (f[i][j][k] & (a[i + x][j + y] == '*'));
                  else
                    f[i][j][k] = (f[i][j][k] & (a[i + x][j + y] == '.'));
                } else {
                  if ((1 << p) & pat)
                    f[i][j][k] = (f[i][j][k] & black[i + x][j + y][k - 1]);
                  else
                    f[i][j][k] = (f[i][j][k] & f[i + x][j + y][k - 1]);
                }
                ++p;
              }
            if ((k > 1) && (f[i][j][k])) ++result;
          } else
            f[i][j][k] = false;
    }
  }
}
void output() { printf("%d\n", result); }
int main() {
  init();
  work();
  output();
  return 0;
}
