#include <bits/stdc++.h>
using namespace std;
inline int readint() {
  char c = ' ';
  int g = 0, l = 1;
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') l = -1, c = getchar();
  while (isdigit(c)) g = g * 10 + c - 48, c = getchar();
  return g * l;
}
const int INF = (-1u) >> 2;
const double EPS = 1e-8;
const double PI = acos(-1.0);
const int MAXN = 1010;
int maps[10][MAXN][MAXN];
char str[MAXN][MAXN];
int main() {
  int n, m, i, j, k, l, p;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%s", str[i] + 1);
  }
  memset((maps), -1, sizeof(maps));
  for (i = 1; i <= n - 1; i++) {
    for (j = 1; j <= m - 1; j++) {
      maps[0][i][j] = 0;
      if (str[i][j] == '*') maps[0][i][j] += 1;
      if (str[i][j + 1] == '*') maps[0][i][j] += 2;
      if (str[i + 1][j] == '*') maps[0][i][j] += 4;
      if (str[i + 1][j + 1] == '*') maps[0][i][j] += 8;
    }
  }
  int ans = 0;
  for (k = 1; k <= 7; k++) {
    l = (1 << k);
    for (i = 1; i <= n - 2 * l + 1; i++) {
      for (j = 1; j <= m - 2 * l + 1; j++) {
        if (maps[k - 1][i][j] < 0) continue;
        int tmp;
        if (maps[k - 1][i][j] == 15) {
          for (p = 1; p < 4; p++) {
            if (maps[k - 1][i + l * (p >= 2)][j + l * (p & 1)] != 15) break;
          }
          if (p == 4)
            tmp = 15;
          else
            tmp = maps[k - 1][i + l * (p >= 2)][j + l * (p & 1)];
        } else
          tmp = maps[k - 1][i][j];
        for (p = 0; p < 4; p++) {
          if (tmp & (1 << p)) {
            if (maps[k - 1][i + l * (p >= 2)][j + l * (p & 1)] != 15) {
              tmp = -1;
              break;
            }
          } else {
            if (tmp != maps[k - 1][i + l * (p >= 2)][j + l * (p & 1)]) {
              tmp = -1;
              break;
            }
          }
        }
        maps[k][i][j] = tmp;
        if (maps[k][i][j] >= 0) ans++;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
