#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
char s[504][504];
int sum[504][504];
bool dp[8][16][504][504];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      sum[i][j] =
          sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + (s[i][j] == '*');
  for (int i = 1; i < n; i++)
    for (int j = 1; j < m; j++) {
      int bmask = 0;
      for (int k = 0; k < 2; k++)
        for (int l = 0; l < 2; l++)
          if (s[i + k][j + l] == '*') bmask |= (1 << (2 * k + l));
      dp[0][bmask][i][j] = true;
    }
  for (int lvl = 1; (1 << (lvl + 1)) <= min(n, m); lvl++)
    for (int bm = 0; bm < 16; bm++)
      for (int i = 1; i <= n - (1 << (lvl + 1)) + 1; i++)
        for (int j = 1; j <= m - (1 << (lvl + 1)) + 1; j++) {
          bool ok = true;
          for (int k = 0; k < 2 && ok; k++)
            for (int l = 0; l < 2 && ok; l++) {
              if (bm & (1 << (2 * k + l))) {
                int pl = j + l * (1 << lvl) - 1;
                int pr = pl + (1 << lvl);
                int pu = i + k * (1 << lvl) - 1;
                int pd = pu + (1 << lvl);
                if (sum[pd][pr] - sum[pd][pl] - sum[pu][pr] + sum[pu][pl] !=
                    (1 << (2 * lvl)))
                  ok = false;
              } else if (dp[lvl - 1][bm][i + k * (1 << lvl)]
                           [j + l * (1 << lvl)] == false)
                ok = false;
            }
          if (ok) dp[lvl][bm][i][j] = true, ans++;
        }
  printf("%d\n", ans);
  return 0;
}
