#include <bits/stdc++.h>   using namespace std;   unsigned long long int n, m, l;   unsigned long long int r, k, nn;   template <class T>   inline T min(T a, T b) {     return ((a < b) ? a : b);   }   char frac[9][500][500];   string p[500];   char isfrac(char a, char b, char c, char d) {     char mx = max(max(a, b), max(c, d));     return (         (((mx & 8) ? (a == mx) : (a == 0)) && ((mx & 4) ? (b == mx) : (b == 0)) &&          ((mx & 2) ? (c == mx) : (c == 0)) && ((mx & 1) ? (d == mx) : (d == 0)))             ? mx             : -1);   }   int main(int argc, char** argv) {     cin >> n >> m;     for (int i = 0; i < n; ++i) {       cin >> p[i];     }     char f = 0;     for (int i = 0; i < (n - 1); ++i) {       for (int j = 0; j < (m - 1); ++j) {         f = 0;         if (p[i][j] ==  . ) {           f += 8;         }         if (p[i][j + 1] ==  . ) {           f += 4;         }         if (p[i + 1][j] ==  . ) {           f += 2;         }         if (p[i + 1][j + 1] ==  . ) {           f += 1;         }         frac[0][i][j] = f;       }     }     int cnt = 0;     int l = 1;     int pw = 2;     while (((2 * pw) <= n) && ((2 * pw) <= m)) {       for (int i = 0; i <= (n - 2 * pw); ++i) {         for (int j = 0; j <= (m - 2 * pw); ++j) {           frac[l][i][j] =               isfrac(frac[l - 1][i][j], frac[l - 1][i][j + pw],                      frac[l - 1][i + pw][j], frac[l - 1][i + pw][j + pw]);           if (frac[l][i][j] >= 0) {             cnt++;           }         }       }       ++l;       pw *= 2;     }     cout << cnt;     return 0;   }   