#include <bits/stdc++.h>
using namespace std;
const int tope = 500;
int n, m;
int v[15][tope][tope];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char c;
      cin >> c;
      if (c == '.')
        v[0][i][j] = 0;
      else
        v[0][i][j] = 1;
    }
  }
  for (int i = 0; i < n - 1; i++)
    for (int j = 0; j < m - 1; j++)
      v[1][i][j] = (v[0][i][j] << 3) + (v[0][i][j + 1] << 2) +
                   (v[0][i + 1][j] << 1) + (v[0][i + 1][j + 1]);
  int count = 0;
  for (int k = 2, e = 2; 2 * e <= n and 2 * e <= m; k++, e *= 2) {
    int(&vold)[tope][tope] = v[k - 1];
    int(&vnew)[tope][tope] = v[k];
    for (int i = 0; i <= n - 2 * e; i++) {
      for (int j = 0; j <= m - 2 * e; j++) {
        if (vold[i][j] == -1 or vold[i][j + e] == -1 or vold[i + e][j] == -1 or
            vold[i + e][j + e] == -1) {
          vnew[i][j] = -1;
        } else {
          vnew[i][j] =
              ((vold[i][j] == 15) << 3) + ((vold[i][j + e] == 15) << 2) +
              ((vold[i + e][j] == 15) << 1) + ((vold[i + e][j + e] == 15));
          if (vold[i][j] != 15 and vold[i][j] != vnew[i][j])
            vnew[i][j] = -1;
          else if (vold[i][j + e] != 15 and vold[i][j + e] != vnew[i][j])
            vnew[i][j] = -1;
          else if (vold[i + e][j] != 15 and vold[i + e][j] != vnew[i][j])
            vnew[i][j] = -1;
          else if (vold[i + e][j + e] != 15 and
                   vold[i + e][j + e] != vnew[i][j])
            vnew[i][j] = -1;
          else
            count++;
        }
      }
    }
  }
  cout << count << endl;
}
