#include <bits/stdc++.h>
using namespace std;
int cond = 1;
const int dl[4][2] = {{0, 0}, {0, 1}, {1, 0}, {1, 1}};
const int MAXN = 513;
const int MAXDL = 11;
const int MAXP = 17;
bool result[MAXDL][MAXN][MAXN][MAXP];
char t[MAXN][MAXN];
int n, m;
pair<int, int> getPos(int i, int j, int len, int slot) {
  assert(0 <= slot && slot <= 3);
  int px = i + dl[slot][0] * (1 << (len - 1));
  int py = j + dl[slot][1] * (1 << (len - 1));
  return make_pair(px, py);
}
bool checkPattern(int i, int j, int len, int pattern) {
  for (int zn = 0; zn < (4); zn++) {
    pair<int, int> pz = getPos(i, j, len, zn);
    if (pattern & (1 << zn)) {
      if (!result[len - 1][pz.first][pz.second][(1 << 4) - 1]) {
        return false;
      }
    } else {
      if (len == 1) {
        if (!result[len - 1][pz.first][pz.second][0]) {
          return false;
        }
      } else {
        if (!result[len - 1][pz.first][pz.second][pattern]) {
          return false;
        }
      }
    }
  }
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (n); i++) {
    scanf("%s", t[i]);
  }
  for (int k = 0; k < (MAXDL); k++)
    for (int i = 0; i < (MAXN); i++)
      for (int j = 0; j < (MAXN); j++)
        for (int l = 0; l < (MAXP); l++) result[k][i][j][l] = false;
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (m); j++) {
      int val = 0;
      if (t[i][j] == '*')
        val = (1 << 4) - 1;
      else
        val = 0;
      result[0][i][j][val] = true;
    }
  }
  int wynik = 0;
  for (int len = (1); len <= (8); len++) {
    for (int i = 0; i < (n); i++) {
      for (int j = 0; j < (m); j++) {
        if (i + (1 << len) - 1 < n && j + (1 << len) - 1 < m) {
          bool ok = false;
          for (int pattern = 0; pattern < ((1 << 4)); pattern++) {
            result[len][i][j][pattern] = checkPattern(i, j, len, pattern);
            if (result[len][i][j][pattern] && len >= 2) {
              ok = true;
            }
          }
          if (ok) {
            wynik++;
          }
        }
      }
    }
  }
  cout << wynik << endl;
  return 0;
}
