#include <bits/stdc++.h>
int a[510][510];
int d[10][510][510];
int main() {
  int n, m, i, j, k, ii, ans, l, cur;
  char c;
  scanf("%d%d%*c", &n, &m);
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j) scanf("%c", &c), a[i][j] = c == '*';
    scanf("%*c");
  }
  for (i = 1; i <= n - 1; ++i)
    for (j = 1; j <= m - 1; ++j)
      d[1][i][j] = (a[i][j]) | (a[i][j + 1] << 1) | (a[i + 1][j] << 2) |
                   (a[i + 1][j + 1] << 3);
  ans = 0;
  for (k = 2; k < 10; ++k) {
    l = 1 << k;
    for (i = 1; i <= n - l + 1; ++i)
      for (j = 1; j <= m - l + 1; ++j) {
        d[k][i][j] = -1;
        int dd[4] = {d[k - 1][i][j], d[k - 1][i][j + l / 2],
                     d[k - 1][i + l / 2][j], d[k - 1][i + l / 2][j + l / 2]};
        for (ii = 0; ii < 4; ++ii)
          if (dd[ii] == -1) continue;
        for (cur = 0; cur < 16; ++cur) {
          for (ii = 0; ii < 4; ++ii)
            if ((cur >> ii) & 1) {
              if (dd[ii] != 15) break;
            } else if (dd[ii] != cur)
              break;
          if (ii == 4) {
            ++ans;
            d[k][i][j] = cur;
            break;
          }
        }
      }
  }
  printf("%d\n", ans);
  return 0;
}
