#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int a[505][505][12], b[4];
char s[505][505];
int i, j, n, m, k, l;
int solve(int rt) {
  for (i = 0; i < 4; i++) b[i] = ((rt >> i) & 1);
  int ans = 0;
  for (k = 0; k < 10; k++) {
    for (i = 1; i <= n; i++) {
      if (i - 1 + (1 << (k + 1)) > n) break;
      for (j = 1; j <= m; j++) {
        if (j - 1 + (1 << (k + 1)) > m) break;
        int s = (1 << k);
        if (rt != 15 && a[i][j][k] == b[0] && a[i][j + s][k] == b[1] &&
            a[i + s][j][k] == b[2] && a[i + s][j + s][k] == b[3]) {
          a[i][j][k + 1] = 0;
          if (k > 0) ans++;
        } else if (a[i][j][k] == 1 && a[i][j + s][k] == 1 &&
                   a[i + s][j][k] == 1 && a[i + s][j + s][k] == 1) {
          a[i][j][k + 1] = 1;
          if (rt == 15 && k > 0) ans++;
        } else
          a[i][j][k + 1] = -1;
      }
    }
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%s", s[i]);
    for (j = 0; j < m; j++)
      if (s[i][j] == '.')
        a[i][j + 1][0] = 0;
      else
        a[i][j + 1][0] = 1;
  }
  int ans = 0;
  for (int rt = 0; rt < (1 << 4); rt++) ans += solve(rt);
  printf("%d\n", ans);
  return 0;
}
