#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "{";
  for (const T &a : v) out << a << ", ";
  out << "}";
  return out;
}
template <typename S, typename T>
ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}
int z, n, m;
string s[507];
int tab[507][507];
int ok[2][507][507];
int black[10][507][507];
int ans;
int dx[] = {0, 0, 1, 1};
int dy[] = {0, 1, 0, 1};
int bit(int first, int b) {
  assert((first & (1 << b)) >> b <= 1);
  return (first & (1 << b)) >> b;
}
int check_black(int i, int j, int lvl) {
  if (black[lvl][i][j] != -1) return black[lvl][i][j];
  if (lvl == 0) {
    int good = 1;
    for (int f = 0; f < (int)4; f++) good &= (tab[i + dy[f]][j + dx[f]] == 1);
    return black[lvl][i][j] = good;
  }
  if (i + (1 << (lvl + 1)) > n || j + (1 << (lvl + 1)) > m)
    return black[lvl][i][j] = 0;
  black[lvl][i][j] = 1;
  for (int f = 0; f < (int)4; f++)
    black[lvl][i][j] &=
        check_black(i + (dy[f] << lvl), j + (dx[f] << lvl), lvl - 1);
  return black[lvl][i][j];
}
int check(int i, int j, int pat, int lvl) {
  if (ok[lvl % 2][i][j] != -1) return ok[lvl % 2][i][j];
  if (i + (1 << (lvl + 1)) > n || j + (1 << (lvl + 1)) > m) return 0;
  int good = 1;
  if (lvl == 0) {
    for (int f = 0; f < (int)4; f++)
      good &= (tab[i + dy[f]][j + dx[f]] == bit(pat, f));
    return ok[lvl % 2][i][j] = good;
  }
  for (int f = 0; f < (int)4; f++) {
    int ni = i + (dy[f] << lvl), nj = j + (dx[f] << lvl);
    if (bit(pat, f) == 1)
      good &= black[lvl - 1][ni][nj];
    else
      good &= ok[1 - lvl % 2][ni][nj];
  }
  if (good && lvl) {
    ans++;
  }
  return ok[lvl % 2][i][j] = good;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < (int)n; i++) cin >> s[i];
  memset(black, -1, sizeof black);
  for (int i = 0; i < (int)n; i++)
    for (int j = 0; j < (int)m; j++) tab[i][j] = s[i][j] == '*';
  for (int i = 0; i < (int)n; i++)
    for (int j = 0; j < (int)m; j++)
      for (int lvl = 0; lvl < (int)8; lvl++) check_black(i, j, lvl);
  for (int pat = 0; pat < (int)16; pat++)
    for (int lvl = 0; lvl < (int)8; lvl++) {
      memset(ok[lvl % 2], -1, sizeof ok[lvl % 2]);
      for (int i = 0; i < (int)n; i++)
        for (int j = 0; j < (int)m; j++) check(i, j, pat, lvl);
    }
  cout << ans << endl;
}
