#include <bits/stdc++.h>
using namespace std;
class pattern;
int n, m, ctr = 0, len = 2;
string s[512];
map<pair<int, int>, pattern> M;
map<pair<int, int>, pattern> tempM;
class pattern {
 public:
  bool arr[2][2];
  bool isBlack;
  void operator=(const pattern& another) {
    isBlack = true;
    for (int i = 0; i < 2; ++i)
      for (int j = 0; j < 2; ++j) {
        arr[i][j] = another.arr[i][j];
        if (arr[i][j]) isBlack = false;
      }
  }
  void naddaf() {
    isBlack = 0;
    for (int i = 0; i < 2; ++i)
      for (int j = 0; j < 2; ++j) arr[i][j] = 1;
  }
  void print() {
    cout << isBlack << endl;
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) cout << arr[i][j];
      cout << endl;
    }
    cout << endl;
  }
  bool operator!=(const pattern& another) {
    for (int i = 0; i < 2; ++i)
      for (int j = 0; j < 2; ++j)
        if (arr[i][j] != another.arr[i][j]) return true;
    return false;
  }
};
pattern tempPattern;
bool isFractal(int x, int y) {
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j) {
      if (M.find(make_pair(x + i * len, y + j * len)) == M.end()) return false;
      tempPattern.arr[i][j] = !(M[make_pair(x + i * len, y + j * len)].isBlack);
    }
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j)
      if (!M[make_pair(x + i * len, y + j * len)].isBlack &&
          tempPattern != M[make_pair(x + i * len, y + j * len)])
        return false;
  tempM[make_pair(x, y)] = tempPattern;
  return true;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> s[i];
  for (int i = 0; i + len <= n; ++i)
    for (int j = 0; j + len <= m; ++j) {
      for (int k = 0; k < 2; ++k)
        for (int l = 0; l < 2; ++l)
          tempPattern.arr[k][l] = (s[i + k][j + l] == '.');
      M[make_pair(i, j)] = tempPattern;
    }
  for (; len < 512; len *= 2) {
    tempM.clear();
    for (map<pair<int, int>, pattern>::iterator it = M.begin(); it != M.end();
         ++it) {
      if (isFractal(it->first.first, it->first.second)) ++ctr;
    }
    M = tempM;
  }
  cout << ctr;
  return 0;
}
