#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  vector<string> b;
  string s;
  getline(cin, s);
  stringstream ss(s);
  int h, w;
  ss >> h >> w;
  int i, j, k, x, y;
  for (i = 0; i < h; ++i) {
    getline(cin, s);
    s.resize(w);
    b.push_back(s);
  }
  static int dp[9][500][500];
  memset(dp, -1, sizeof(dp));
  for (i = 0; i < 16; ++i) {
    char pat[4];
    for (j = 0; j < 4; ++j) {
      pat[j] = (i & (1 << j)) ? '*' : '.';
    }
    for (y = 0; y < h - 1; ++y) {
      for (x = 0; x < w - 1; ++x) {
        if (memcmp(b[y].data() + x, pat, 2) == 0 &&
            memcmp(b[y + 1].data() + x, pat + 2, 2) == 0) {
          dp[0][y][x] = i;
        }
      }
    }
  }
  int ans = 0;
  k = 2;
  for (i = 0; i < 8; ++i) {
    for (j = 0; j < 16; ++j) {
      for (y = 0; y <= h - k * 2; ++y) {
        for (x = 0; x <= w - k * 2; ++x) {
          if (dp[i][y][x] == ((j & 1) ? 15 : j) &&
              dp[i][y][x + k] == ((j & 2) ? 15 : j) &&
              dp[i][y + k][x] == ((j & 4) ? 15 : j) &&
              dp[i][y + k][x + k] == ((j & 8) ? 15 : j)) {
            dp[i + 1][y][x] = j;
            ++ans;
          }
        }
      }
    }
    k *= 2;
  }
  cout << ans << endl;
  return 0;
}
