#include <bits/stdc++.h>
int state[500][500][10];
int main() {
  int n, m, x[4] = {0, 0, 1, 1}, y[4] = {0, 1, 0, 1}, ans = 0;
  char field[500][500 + 1];
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", field[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (field[i][j] == '.')
        field[i][j] = 0;
      else
        field[i][j] = 1;
  for (int level = 0; level < 10; level++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < m; k++) state[j][k][level] = -1;
  {
    int level = 0;
    int i = 1;
    for (int j = 0; j + i < n; j++)
      for (int k = 0; k + i < m; k++) {
        state[j][k][level] = 0;
        for (int mul = 1, l = 0; l < 4; l++, mul *= 2)
          state[j][k][level] += mul * field[j + x[l] * i][k + y[l] * i];
      }
  }
  for (int level = 1, i = 2; i < n && i < m; i *= 2, level++)
    for (int j = 0; j + i < n; j++)
      for (int k = 0; k + i < m; k++) {
        int mask = 0;
        bool flag = true;
        for (int mul = 1, l = 0; l < 4; l++, mul *= 2)
          if (state[j + x[l] * i][k + y[l] * i][level - 1] == 15) mask += mul;
        for (int l = 0; l < 4; l++)
          if (state[j + x[l] * i][k + y[l] * i][level - 1] != 15 &&
              state[j + x[l] * i][k + y[l] * i][level - 1] != mask)
            flag = false;
        if (flag) {
          state[j][k][level] = mask;
          ans++;
        }
      }
  printf("%d\n", ans);
  return 0;
}
