#include <bits/stdc++.h>
using namespace std;
int n, m;
char ch[505];
int a[505][505], b[505][505];
long long ans;
int d[505][505], l[505][505], s[505][505], f[10][505][505];
int md[20][2][2];
int main() {
  memset(a, -1, sizeof(a));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", ch + 1);
    for (int j = 1; j <= m; ++j) {
      a[i][j] = ch[j] == '*';
    }
  }
  for (int i = 0; i < (1 << 4); ++i) {
    for (int j = 0; j < 2; ++j) {
      for (int k = 0; k < 2; ++k) {
        if (i & (1 << (j * 2 + k))) {
          md[i][j][k] = 1;
        }
      }
    }
  }
  for (int i = n; i >= 1; --i) {
    for (int j = 1; j <= m; ++j) {
      if (a[i][j] == 0) continue;
      d[i][j] = d[i + 1][j] + 1;
      l[i][j] = l[i][j - 1] + 1;
      s[i][j] = min(min(d[i][j], l[i][j]), s[i + 1][j - 1] + 1);
    }
  }
  for (int st = 0; st < (1 << 4); ++st) {
    memset(f, 0, sizeof(f));
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        if (a[i][j] == md[st][0][1] && a[i][j - 1] == md[st][0][0] &&
            a[i + 1][j] == md[st][1][1] && a[i + 1][j - 1] == md[st][1][0]) {
          f[1][i][j] = 1;
        }
      }
    }
    for (int t = 2, len = 4; len <= min(n, m); ++t, len *= 2) {
      for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
          if (md[st][0][1]) {
            if (s[i][j] < len / 2) continue;
          } else {
            if (f[t - 1][i][j] == 0) continue;
          }
          if (md[st][0][0]) {
            if (s[i][j - len / 2] < len / 2) continue;
          } else {
            if (f[t - 1][i][j - len / 2] == 0) continue;
          }
          if (md[st][1][0]) {
            if (s[i + len / 2][j - len / 2] < len / 2) continue;
          } else {
            if (f[t - 1][i + len / 2][j - len / 2] == 0) continue;
          }
          if (md[st][1][1]) {
            if (s[i + len / 2][j] < len / 2) continue;
          } else {
            if (f[t - 1][i + len / 2][j] == 0) continue;
          }
          f[t][i][j] = 1;
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
