#include <bits/stdc++.h>
using namespace std;
int R, C;
vector<string> M;
bool B[500][500][10];
int F[500][500][10];
int I[4], J[4];
int main() {
  while (cin >> R >> C) {
    M.resize(R);
    for (int i = 0; i < R; i++) cin >> M[i];
    memset(B, 0, sizeof(B));
    memset(F, -1, sizeof(F));
    for (int i = 0; i < R; i++)
      for (int j = 0; j < C; j++)
        if (M[i][j] == '*') B[i][j][0] = 1;
    int L = 1;
    for (int k = 1; k < 10; k++) {
      L *= 2;
      for (int i = 0; i < R; i++)
        for (int j = 0; j < C; j++)
          if (i + L <= R && j + L <= C)
            B[i][j][k] =
                (B[i][j][k - 1] && B[i + L / 2][j][k - 1] &&
                 B[i][j + L / 2][k - 1] && B[i + L / 2][j + L / 2][k - 1]);
    }
    for (int i = 0; i + 1 < R; i++) {
      for (int j = 0; j + 1 < C; j++) {
        I[0] = i;
        J[0] = j;
        I[1] = i;
        J[1] = j + 1;
        I[2] = i + 1;
        J[2] = j;
        I[3] = i + 1;
        J[3] = j + 1;
        int mask = 0;
        for (int ii = 0; ii < 4; ii++)
          if (B[I[ii]][J[ii]][0]) mask |= (1 << ii);
        F[i][j][1] = mask;
      }
    }
    int ans = 0;
    L = 2;
    for (int k = 2; k < 10; k++) {
      L *= 2;
      for (int i = 0; i + L <= R; i++) {
        for (int j = 0; j + L <= C; j++) {
          I[0] = i;
          J[0] = j;
          I[1] = i;
          J[1] = j + L / 2;
          I[2] = i + L / 2;
          J[2] = j;
          I[3] = i + L / 2;
          J[3] = j + L / 2;
          for (int mask = 0; mask < (1 << 4); mask++) {
            bool ok = 1;
            for (int ii = 0; ok && ii < 4; ii++) {
              if (mask & (1 << ii))
                ok = ok && B[I[ii]][J[ii]][k - 1];
              else
                ok = ok && (F[I[ii]][J[ii]][k - 1] == mask);
            }
            if (ok) {
              F[i][j][k] = mask;
              if (k >= 2) ans++;
              break;
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
