#include <bits/stdc++.h>
using namespace std;
const int N = 507;
int n, m, a[N][N], s[N][N];
bool v[N][N];
char str[N];
int calc(int x0, int y0, int x1, int y1) {
  return s[x1][y1] - s[x1][y0 - 1] - s[x0 - 1][y1] + s[x0 - 1][y0 - 1];
}
int solve() {
  int ret = 0;
  for (int mask = (0), I = (16); mask < I; ++mask) {
    for (int i = (1), I = (n); i < I; ++i)
      for (int j = (1), I = (m); j < I; ++j) {
        int tmp = (a[i][j]) | (a[i][j + 1] << 1) | (a[i + 1][j] << 2) |
                  (a[i + 1][j + 1] << 3);
        v[i][j] = tmp == mask;
      }
    for (int d = (2), I = (10); d < I; ++d) {
      if ((1 << d) > min(n, m)) break;
      for (int i = (1), I = (n - (1 << d) + 2); i < I; ++i)
        for (int j = (1), I = (m - (1 << d) + 2); j < I; ++j) {
          int D = 1 << (d - 1);
          bool flag = true;
          for (int k = (0), I = (4); k < I; ++k) {
            int x = i + (k >> 1 & 1) * D;
            int y = j + (k & 1) * D;
            if (mask >> k & 1) {
              flag &= calc(x, y, x + D - 1, y + D - 1) == D * D;
            } else {
              flag &= v[x][y];
            }
          }
          v[i][j] = flag, ret += flag;
        }
    }
  }
  return ret;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1), I = (n + 1); i < I; ++i) {
    scanf(" %s", str + 1);
    for (int j = (1), I = (m + 1); j < I; ++j) a[i][j] = str[j] == '*';
  }
  for (int i = (1), I = (n + 1); i < I; ++i)
    for (int j = (1), I = (m + 1); j < I; ++j)
      s[i][j] = a[i][j] + s[i][j - 1] + s[i - 1][j] - s[i - 1][j - 1];
  printf("%d", solve());
  return 0;
}
