#include <bits/stdc++.h>
int N, M;
int board[555][555];
int D[555][555][10];
int ans;
void pre_2by2_Calc() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      int state = 0, p = 0;
      for (int x = 0; x < 2; x++) {
        for (int y = 0; y < 2; y++) {
          if (board[i + x][j + y]) state |= 1 << p;
          p++;
        }
      }
      D[i][j][1] = state;
    }
  }
}
void getFrac() {
  for (int size = 4, r = 2; size <= N && size <= M; size *= 2, r++) {
    for (int i = 0; i + size - 1 < N; i++) {
      for (int j = 0; j + size - 1 < M; j++) {
        int state = 0, p = 0;
        for (int x = 0; x < 2; x++) {
          for (int y = 0; y < 2; y++) {
            if (D[i + x * size / 2][j + y * size / 2][r - 1] == (1 << 4) - 1)
              state |= 1 << p;
            p++;
          }
        }
        int ok = 1;
        for (int x = 0; x < 2; x++) {
          for (int y = 0; y < 2; y++) {
            if (D[i + x * size / 2][j + y * size / 2][r - 1] == (1 << 4) - 1)
              continue;
            if (D[i + x * size / 2][j + y * size / 2][r - 1] != state) ok = 0;
          }
        }
        if (ok) {
          D[i][j][r] = state;
          ans++;
        } else
          D[i][j][r] = -1;
      }
    }
  }
}
int main() {
  char temp[555];
  scanf("%d %d", &N, &M);
  for (int i = 0; i < N; i++) {
    scanf("%s", temp);
    for (int j = 0; j < M; j++) {
      board[i][j] = temp[j] == '*';
    }
  }
  pre_2by2_Calc();
  getFrac();
  printf("%d", ans);
  return 0;
}
