#include <bits/stdc++.h>
using namespace std;
struct no {
  int d, r, c;
  no(int d, int r, int c) : d(d), r(r), c(c) {}
};
int n, m, ans;
char mat[501];
bool dp[2][16][501][501];
vector<no> v;
bool pd(int op, int d, int r, int c) {
  if (r >= n || c >= m || r < 0 || c < 0) return false;
  return dp[op][d][r][c];
}
void update(int op, int d, int r, int c, int inc) {
  if (pd(op, (d & 1) ? d : 0, r, c) && pd(op, (d & 2) ? d : 0, r, c + inc) &&
      pd(op, (d & 4) ? d : 0, r + inc, c) &&
      pd(op, (d & 8) ? d : 0, r + inc, c + inc)) {
    if (!dp[op ^ 1][d][r][c]) {
      dp[op ^ 1][d][r][c] = true;
      ++ans;
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int r = 0; r < n; ++r) {
    scanf("%s", mat);
    for (int c = 0; c < m; ++c) {
      dp[0][0][r][c] = mat[c] == '*';
      dp[0][1][r][c] = !dp[0][0][r][c];
      for (int d = 2; d < 16; ++d) {
        dp[0][d][r][c] = dp[0][1][r][c];
      }
    }
  }
  for (int inc = 1, t = min(n, m), op = 0; inc <= t; inc <<= 1, op ^= 1) {
    if (inc == 2) ans = 0;
    for (int r = 0; r < n; ++r) {
      for (int c = 0; c < m; ++c) {
        for (int d = 0; d < 16; ++d) {
          if (dp[op][d][r][c]) {
            update(op, d, r, c, inc);
            update(op, d, r - inc, c, inc);
            update(op, d, r, c - inc, inc);
            update(op, d, r - inc, c - inc, inc);
            v.push_back(no(d, r, c));
          }
        }
      }
    }
    for (int i = 0; i < v.size(); ++i) {
      dp[op][v[i].d][v[i].r][v[i].c] = false;
    }
  }
  printf("%d\n", ans);
  return 0;
}
