#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
int N, M, table[550][550], ans;
bool dp[550][550][9][16];
string s;
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(15);
  cin >> N >> M;
  for (int(r) = 1; (r) <= (N); (r)++) {
    cin >> s;
    for (int(c) = 1; (c) <= (M); (c)++) table[r][c] = s[c - 1] == '.';
  }
  for (int(r) = 1; (r) <= (N); (r)++)
    for (int(c) = 1; (c) <= (M); (c)++) {
      int type = 0;
      if (table[r][c]) type += 1 << 0;
      if (table[r][c + 1]) type += 1 << 1;
      if (table[r + 1][c]) type += 1 << 2;
      if (table[r + 1][c + 1]) type += 1 << 3;
      dp[r][c][1][type] = true;
    }
  for (int(s) = 1; (s) <= (7); (s)++) {
    int ss = 1 << s;
    for (int(r) = 1; (r) <= (N); (r)++)
      for (int(c) = 1; (c) <= (M); (c)++)
        if (r + (ss << 1) - 1 <= N && c + (ss << 1) - 1 <= M) {
          for (int(type) = 0; (type) < (16); (type)++) {
            dp[r][c][s + 1][type] = true;
            dp[r][c][s + 1][type] &= dp[r][c][s][(type >> 0) & 1 ? type : 0];
            dp[r][c][s + 1][type] &=
                dp[r][c + ss][s][(type >> 1) & 1 ? type : 0];
            dp[r][c][s + 1][type] &=
                dp[r + ss][c][s][(type >> 2) & 1 ? type : 0];
            dp[r][c][s + 1][type] &=
                dp[r + ss][c + ss][s][(type >> 3) & 1 ? type : 0];
            if (dp[r][c][s + 1][type]) {
              ans++;
            }
          }
        }
  }
  cout << ans << endl;
}
