#include <bits/stdc++.h>
using namespace std;
int sum[512][512][10];
int pd[512][512][10];
int dx[5] = {0, 0, 1, 1};
int dy[5] = {0, 1, 0, 1};
int n, m, ans;
char c;
int main() {
  int i, j, k, t;
  cin >> n >> m;
  for (i = 1; i <= n; ++i) {
    cin.get();
    for (j = 1; j <= m; ++j) {
      c = cin.get();
      sum[i][j][0] = (c == '*' ? 1 : 0);
    }
  }
  for (k = 1; (1 << k) <= n && (1 << k) <= m; ++k)
    for (i = 1; i + (1 << k) - 1 <= n; ++i)
      for (j = 1; j + (1 << k) - 1 <= m; ++j) {
        for (t = 0; t < 4; ++t) {
          sum[i][j][k] +=
              sum[i + (dx[t] << (k - 1))][j + (dy[t] << (k - 1))][k - 1];
          if (sum[i + (dx[t] << (k - 1))][j + (dy[t] << (k - 1))][k - 1] ==
              (1 << (2 * (k - 1)))) {
            pd[i][j][k] ^= (1 << t);
          }
        }
        if (k > 1) {
          for (t = 0; t < 4; ++t)
            if ((pd[i][j][k] & (1 << t)) == 0 &&
                pd[i][j][k] !=
                    pd[i + (dx[t] << (k - 1))][j + (dy[t] << (k - 1))][k - 1]) {
              if (i == 1 && j == 1 && k == 2)
                cerr << "MORENA: " << ((pd[i][j][k] & (1 << t)) == 0) << " "
                     << t << " ";
              pd[i][j][k] = -1;
              break;
            }
          if (pd[i][j][k] != -1) ++ans;
        }
      }
  cout << ans;
  return 0;
}
