Problem: Little Vasya likes painting fractals very much.

He does it like this. First the boy cuts out a 2 × 2-cell square out of squared paper. Then he paints some cells black. The boy calls the cut out square a fractal pattern. Then he takes a clean square sheet of paper and paints a fractal by the following algorithm:

  1. He divides the sheet into four identical squares. A part of them is painted black according to the fractal pattern. 
  2. Each square that remained white, is split into 4 lesser white squares, some of them are painted according to the fractal pattern. Each square that remained black, is split into 4 lesser black squares. 



In each of the following steps step 2 repeats. To draw a fractal, the boy can make an arbitrary positive number of steps of the algorithm. But he need to make at least two steps. In other words step 2 of the algorithm must be done at least once. The resulting picture (the square with painted cells) will be a fractal. The figure below shows drawing a fractal (here boy made three steps of the algorithm).

<image>

One evening Vasya got very tired, so he didn't paint the fractal, he just took a sheet of paper, painted a n × m-cell field. Then Vasya paint some cells black. 

Now he wonders, how many squares are on the field, such that there is a fractal, which can be obtained as described above, and which is equal to that square. Square is considered equal to some fractal if they consist of the same amount of elementary not divided cells and for each elementary cell of the square corresponding elementary cell of the fractal have the same color.

Input

The first line contains two space-separated integers n, m (2 ≤ n, m ≤ 500) — the number of rows and columns of the field, correspondingly. 

Next n lines contain m characters each — the description of the field, painted by Vasya. Character "." represents a white cell, character "*" represents a black cell.

It is guaranteed that the field description doesn't contain other characters than "." and "*".

Output

On a single line print a single integer — the number of squares on the field, such that these squares contain a drawn fractal, which can be obtained as described above.

Examples

Input

6 11
......*.***
*.*.*....**
.***....*.*
..***.*....
.*.*.....**
......*.*..


Output

3


Input

4 4
..**
..**
....
....


Output

0

Note

The answer for the first sample is shown on the picture below. Fractals are outlined by red, blue and green squares.

<image>

The answer for the second sample is 0. There is no fractal, equal to the given picture.

<image>

Solution (in CPP):

Solution:
#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;
}