#include <bits/stdc++.h>
using namespace std;
const double eps = 1.0e-11;
const double pi = acos(-1.0);
vector<string> d;
vector<string> patt;
vector<vector<vector<string> > > frac;
map<long long, set<pair<long long, long long> > > hashes;
const long long base1 = 107;
const long long base2 = 109;
const long long mod1 = 1000000007;
const long long mod2 = 1000000009;
long long t1 = 0, t2 = 0;
long long n, m;
long long res = 0;
vector<vector<pair<long long, long long> > > values_of_hash;
void gen(long long tp, long long lev = 4) {
  frac[tp][lev].resize(lev, string(lev, ' '));
  for (long long i = 0; i < 2; i++)
    for (long long j = 0; j < 2; j++) {
      if (frac[tp][2][i][j] == '*')
        for (long long dx = 0; dx < lev / 2; dx++)
          for (long long dy = 0; dy < lev / 2; dy++)
            frac[tp][lev][i * (lev / 2) + dx][j * (lev / 2) + dy] = '*';
      else
        for (long long dx = 0; dx < lev / 2; dx++)
          for (long long dy = 0; dy < lev / 2; dy++)
            frac[tp][lev][i * (lev / 2) + dx][j * (lev / 2) + dy] =
                frac[tp][lev / 2][dx][dy];
    }
  if (lev < 250) gen(tp, lev * 2);
}
long long binpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n) {
    if (n & 1) {
      res *= a, res %= mod;
    }
    a *= a;
    a %= mod;
    n /= 2;
  }
  return res;
}
void Solve(long long dim) {
  long long bs1 = binpow(base1, dim, mod1), bs2 = binpow(base2, dim, mod2);
  values_of_hash.resize(n, vector<pair<long long, long long> >(m - dim + 1));
  for (long long i = 0; i < n; i++) {
    long long hs1 = 0, hs2 = 0;
    for (long long j = 0; j < dim; j++)
      hs1 += d[i][j], hs1 *= base1, hs1 %= mod1, hs2 += d[i][j], hs2 *= base2,
          hs2 %= mod2;
    values_of_hash[i][0] = make_pair(hs1, hs2);
    for (long long j = dim; j <= m - 1; j++) {
      hs1 -= bs1 * d[i][j - dim], hs2 -= bs2 * d[i][j - dim];
      hs1 %= mod1, hs2 %= mod2;
      hs1 += mod1, hs2 += mod2;
      hs1 %= mod1, hs2 %= mod2;
      hs1 += d[i][j], hs2 += d[i][j];
      hs1 *= base1, hs2 *= base2;
      hs1 %= mod1, hs2 %= mod2;
      values_of_hash[i][j - dim + 1] = make_pair(hs1, hs2);
    }
  }
  long long bigb1 = binpow(bs1, dim, mod1);
  long long bigb2 = binpow(bs2, dim, mod2);
  for (long long py = 0; py < m - dim + 1; py++) {
    long long sv1 = 0, sv2 = 0;
    for (long long px = 0; px < dim; px++) {
      sv1 += values_of_hash[px][py].first, sv1 *= bs1, sv1 %= mod1;
      sv2 += values_of_hash[px][py].second, sv2 *= bs2, sv2 %= mod2;
    }
    if (hashes[dim].count(make_pair(sv1, sv2))) ++res;
    for (long long px = dim; px <= n - 1; px++) {
      sv1 -= bigb1 * values_of_hash[px - dim][py].first;
      sv2 -= bigb2 * values_of_hash[px - dim][py].second;
      sv1 %= mod1, sv1 += mod1, sv1 %= mod1;
      sv2 %= mod2, sv2 += mod2, sv2 %= mod2;
      sv1 += values_of_hash[px][py].first, sv1 *= bs1, sv1 %= mod1;
      sv2 += values_of_hash[px][py].second, sv2 *= bs2, sv2 %= mod2;
      if (hashes[dim].count(make_pair(sv1, sv2))) ++res;
    }
  }
  int b = 2;
}
int main() {
  cin >> n >> m;
  d.resize(n);
  for (long long i = 0; i < n; i++) cin >> d[i];
  patt.resize(2, string(2, ' '));
  frac.resize(16, vector<vector<string> >(500, vector<string>()));
  for (long long i = 0; i < 16; i++) {
    long long t = i;
    for (long long j = 0; j < 4; j++) {
      patt[j / 2][j % 2] = ((t & 1) ? '*' : '.');
      t /= 2;
    }
    frac[i][2] = patt;
    gen(i);
    for (long long j = 2; j <= 500; j *= 2) {
      long long hash1 = 0, hash2 = 0;
      for (long long x = 0; x < j; x++)
        for (long long y = 0; y < j; y++) {
          hash1 += frac[i][j][x][y], hash1 *= base1, hash1 %= mod1;
          hash2 += frac[i][j][x][y], hash2 *= base2, hash2 %= mod2;
        }
      hashes[j].insert(make_pair((hash1 * binpow(base1, j, mod1) % mod1),
                                 (hash2 * binpow(base2, j, mod2) % mod2)));
    }
  }
  for (long long i = 4; i <= min(n, m); i *= 2) {
    Solve(i);
  }
  cout << res << endl;
  return 0;
}
