#include <bits/stdc++.h>
using namespace std;
char onechar() {
  static const int BUFSIZE = 1 << 20;
  static char buf[BUFSIZE], *ptr = buf + BUFSIZE;
  if (ptr == buf + BUFSIZE) fread(ptr = buf, 1, BUFSIZE, stdin);
  return *ptr++;
}
char nextchar() {
  char c;
  while (isspace(c = onechar()))
    ;
  return c;
}
int nextint() {
  char c;
  while (!isdigit(c = onechar()))
    ;
  int ans = c - '0';
  while (isdigit(c = onechar())) ans = ans * 10 + c - '0';
  return ans;
}
string nextstring() {
  char c;
  string ret;
  while (!isspace(c = onechar())) ret += c;
  return ret;
}
template <typename T>
vector<T> &operator+=(vector<T> &v, const T &e) {
  v.push_back(e);
  return v;
}
template <typename T>
string tobin(T n) {
  string ret;
  do ret = char('0' + (n & 1)) + ret;
  while (n /= 2);
  return ret;
}
inline unsigned int nextbitperm(unsigned int mask) {
  unsigned int ile = __builtin_ctz(mask), t = ~(mask >> ile),
               q = __builtin_ctz(t);
  return ~(((((((t >> q) - 1) << 1) + 1) << ile) | ((1 << (ile)) - 1))
           << (q - 1));
}
short pyramid[10][1024][1024];
short code(short a, short b, short c, short d, bool exact) {
  short tab[4];
  tab[0] = a;
  tab[1] = b;
  tab[2] = c;
  tab[3] = d;
  short should = (a == 15) + (b == 15) * 2 + (c == 15) * 4 + (d == 15) * 8;
  for (int i = 0; i < 4; i++) {
    if (tab[i] == -1 || (tab[i] != 15 && tab[i] != should * exact)) return -1;
  }
  return should;
}
int main(int argc, char **argv) {
  for (int lev = 0; lev < 10; lev++)
    for (int i = 0; i < 1024; i++)
      for (int j = 0; j < 1024; j++) pyramid[lev][i][j] = -1;
  int counter = 0;
  int R, C;
  scanf("%d %d", &R, &C);
  for (int i = 0; i < R; i++) {
    char buf[1000];
    scanf("%s", buf);
    for (int j = 0; j < C; j++) pyramid[0][i][j] = buf[j] == '.' ? 0 : 15;
    pyramid[0][i][C] = -1;
  }
  for (int lev = 1; lev < 10; lev++) {
    int shift = 1 << (lev - 1);
    for (int r = 0; r < R; r++)
      for (int c = 0; c < C; c++) {
        short tmp = code(pyramid[lev - 1][r][c], pyramid[lev - 1][r][c + shift],
                         pyramid[lev - 1][r + shift][c],
                         pyramid[lev - 1][r + shift][c + shift], lev != 1);
        if (tmp != -1 && lev >= 2) counter++;
        pyramid[lev][r][c] = tmp;
      }
  }
  for (int lev = 0; lev <= 4; lev++) {
    for (int r = 0; r < R; r++) {
      for (int c = 0; c < C; c++)
        fprintf(stderr, "%3d ", (int)pyramid[lev][r][c]);
      fprintf(stderr, "\n");
    }
    fprintf(stderr, "---------------------\n");
  }
  printf("%d\n", counter);
  return 0;
}
