#include <bits/stdc++.h>   using namespace std;   const long long inf = 1LL << 60;   const long long md = 1e9 + 7;   const long double eps = 1e-14;   const int mx = 3010;   int t[mx];   void upd(int p) {     for (++p; p < mx; p += p & -p) ++t[p];   }   int que(int p) {     int res = 0;     for (; p > 0; p -= p & -p) res += t[p];     return res;   }   char zey[mx][mx];   int le[mx][mx], ri[mx][mx];   int solve(vector<int> &a, vector<int> &b) {     int sz = a.size();     if (sz == 0) return 0;     int res = 0;     fill(t, t + sz + 5, 0);     vector<pair<int, int> > bb(sz);     for (int i = (0); i < int(sz); ++i) bb[i] = pair<int, int>(i - b[i] + 1, i);     sort(bb.begin(), bb.end());     int ix = 0;     for (int i = (0); i < int(sz); ++i) {       while (ix < sz && bb[ix].first <= i) upd(bb[ix++].second);       res += que(min(sz, i + a[i])) - i;     }     return res;   }   int main() {     memset(t, 0, sizeof(t));     int n, m;     cin >> n >> m;     for (int i = (0); i < int(n); ++i) scanf(  %s  , zey[i]);     for (int i = (0); i < int(n); ++i) {       le[i][0] = zey[i][0] ==  z ;       ri[i][m - 1] = zey[i][m - 1] ==  z ;     }     for (int i = (0); i < int(n); ++i)       for (int j = (1); j < int(m); ++j)         le[i][j] = zey[i][j] ==  z  ? 1 + le[i][j - 1] : 0;     for (int i = (0); i < int(n); ++i)       for (int j = (m - 1); j-- > int(0);)         ri[i][j] = zey[i][j] ==  z  ? 1 + ri[i][j + 1] : 0;     long long ans = 0;     for (int s = (0); s < int(m + n - 1); ++s) {       vector<int> a, b;       for (int d = (max(0, s - m + 1)); d < int(min(n, s + 1)); ++d) {         if (zey[d][s - d] ==  z ) {           a.push_back(le[d][s - d]);           b.push_back(ri[d][s - d]);         } else {           ans += solve(a, b);           a.clear();           b.clear();         }       }       ans += solve(a, b);     }     cout << ans << endl;   }   