#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  string s[h];
  for (int i = 0; i < h; i++) cin >> s[i];
  int ans = 0;
  for (int i = 0; i < h * w - 2; i++) {
    for (int j = i + 1; j < h * w - 1; j++) {
      for (int k = j + 1; k < h * w; k++) {
        int xa = i / w, xb = i % w, ya = j / w, yb = j % w, za = k / w,
            zb = k % w;
        if (s[xa][xb] == '.' || s[ya][yb] == '.' || s[za][zb] == '.') continue;
        int d1 = abs(xa - ya) + abs(xb - yb), d2 = abs(xa - za) + abs(xb - zb),
            d3 = abs(ya - za) + abs(yb - zb);
        if (d1 == d2 && d1 == d3) ans++;
      }
    }
  }
  cout << ans << endl;
}
