#include <bits/stdc++.h>
using namespace std;
const int N = 500;
int dp[N][N][10], ans = 0, f[N][N], i, j, k, n, m, t, g[4], mask, z;
char a[N][N];
int main() {
  scanf("%d%d\n", &n, &m);
  for (i = 0; i < n; i++) gets(a[i]);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) f[i][j] = a[i][j] == '*';
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      for (t = 0; t < 10; t++) dp[i][j][t] = -1;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      if (i == 0 || j == 0) continue;
      dp[i][j][0] = (f[i - 1][j - 1]) | (f[i - 1][j] * 2) | (f[i][j - 1] * 4) |
                    (f[i][j] * 8);
      for (t = 1; t < 10; t++) {
        z = 1 << t;
        if (i - z < 0 || j - z < 0) continue;
        g[0] = dp[i - z][j - z][t - 1];
        g[1] = dp[i - z][j][t - 1];
        g[2] = dp[i][j - z][t - 1];
        g[3] = dp[i][j][t - 1];
        mask = 0;
        mask *= 2;
        mask |= (g[3] == 15);
        mask *= 2;
        mask |= (g[2] == 15);
        mask *= 2;
        mask |= (g[1] == 15);
        mask *= 2;
        mask |= (g[0] == 15);
        if (g[0] != 15 && g[0] != mask) continue;
        if (g[1] != 15 && g[1] != mask) continue;
        if (g[2] != 15 && g[2] != mask) continue;
        if (g[3] != 15 && g[3] != mask) continue;
        ans++;
        dp[i][j][t] = mask;
      }
    }
  printf("%d\n", ans);
  return 0;
}
