#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int N, M, K, Xn, Yn;
char G[1010][1010], T[200][200];
vector<int> X, Y;
vector<vector<int> > psum, csum;

void prop(vector<vector<int> > &psum) {
    for(int i = 0; i < Yn; i++) {
        for(int j = 0; j < Xn; j++) {
            if(i) psum[i][j] += psum[i - 1][j];
            if(j) psum[i][j] += psum[i][j - 1];
            if(i && j) psum[i][j] -= psum[i - 1][j - 1];
        }
    }
}

int calc(int r1, int c1, int r2, int c2, vector<vector<int> > &psum) {
    int ret = psum[r2][c2];
    if(r1) ret -= psum[r1 - 1][c2];
    if(c1) ret -= psum[r2][c1 - 1];
    if(r1 && c1) ret += psum[r1 - 1][c1 - 1];
    return ret;
}

int A[200], B[200];

int main() {
    scanf("%d %d %d", &N, &M, &K);

    for(int i = 0; i < N; i++) {
        scanf("\n");
        for(int j = 0; j < M; j++) {
            scanf("%c", &G[i][j]);
        }
    }

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            if(i == 0 || G[i - 1][j] != G[i][j]) Y.push_back(i);
            if(j == 0 || G[i][j - 1] != G[i][j]) X.push_back(j);
        }
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    X.resize(unique(X.begin(), X.end()) - X.begin());
    Y.resize(unique(Y.begin(), Y.end()) - Y.begin());
    Xn = X.size();
    Yn = Y.size();
    X.push_back(M);
    Y.push_back(N);

    for(int i = 0; i < Yn; i++) {
        for(int j = 0; j < Xn; j++) {
            T[i][j] = G[ Y[i] ][ X[j] ];
        }
    }

    psum = csum = vector<vector<int> >(Yn, vector<int>(Xn, 0));
    for(int i = 0; i < Yn; i++) {
        for(int j = 0; j < Xn; j++) {
            if(T[i][j] == '.') continue;
            psum[i][j] = 2;
            if((i && T[i - 1][j] == '*') || (j && T[i][j - 1] == '*')) psum[i][j]--;
            if((i != Yn - 1 && T[i + 1][j] == '*') || (j != Xn - 1 && T[i][j + 1] == '*')) psum[i][j]--;

            csum[i][j] = 1;
            if(j == 0 || T[i][j - 1] == '.') csum[i][j] = 0;
        }
    }
    prop(psum);
    prop(csum);

    ll ans = 0;
    for(int i = 0; i < Yn; i++) {
        for(int j = i; j < Yn; j++) {
            for(int a = 0; a < Xn; a++) {
                A[a] = calc(i, a, j, a, psum);
            }
            for(int a = 0; a < Xn; a++) {
                B[a] = calc(i, a, j, a, csum);
            }

            for(int a = 0; a < Xn; a++) {
                int t = Y[i + 1] - Y[i];
                int d = Y[j + 1] - Y[j];
                int l = calc(i, a, j, a, psum)? 1 : X[a + 1] - X[a];
                int r;

                int xt = 0;
                int xd = 0;
                int xl = B[a]? 1 : 0;
                int xr = 0;

                for(int b = a; b < Xn; b++) {
                    if(T[i][b] == '*') t = 1;
                    if(T[j][b] == '*') d = 1;

                    if(i && T[i - 1][b] == '*' && T[i][b] == '*') xt = 1;
                    if(j < Yn - 1 && T[j][b] == '*' && T[j + 1][b] == '*') xd = 1;
                    xr = b < Xn - 1 && B[b + 1];

                    if(xt || xd || xl) break;
                    if(xr) continue;
                    int tmp = calc(i, a, j, b, psum) / 2;

                    if(1 <= tmp && tmp <= 3) {
                        //cout << i << ' ' << a << ' ' << j << ' ' << b << ' ' << tmp << endl;

                        r = A[b]? 1 : X[b + 1] - X[b];
                        ans += 1LL * t * d * l * r;
                    }
                }
            }
        }
    }
    printf("%lld", ans);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int N, M, K, Xn, Yn;
char G[1010][1010], T[200][200];
vector<int> X, Y;
vector<vector<int> > psum, rsum, csum;

void prop(vector<vector<int> > &psum) {
    for(int i = 0; i < Yn; i++) {
        for(int j = 0; j < Xn; j++) {
            if(i) psum[i][j] += psum[i - 1][j];
            if(j) psum[i][j] += psum[i][j - 1];
            if(i && j) psum[i][j] -= psum[i - 1][j - 1];
        }
    }
}

int calc(int r1, int c1, int r2, int c2, vector<vector<int> > &psum) {
    int ret = psum[r2][c2];
    if(r1) ret -= psum[r1 - 1][c2];
    if(c1) ret -= psum[r2][c1 - 1];
    if(r1 && c1) ret += psum[r1 - 1][c1 - 1];
    return ret;
}

bool cross(int r1, int c1, int r2, int c2) {
    if(calc(r1, c1, r1, c2, rsum)) return true;
    if(calc(r1, c1, r2, c1, csum)) return true;
    if(r2 < Yn - 1 && calc(r2 + 1, c1, r2 + 1, c2, rsum)) return true;
    if(c2 < Xn - 1 && calc(r1, c2 + 1, r2, c2 + 1, csum)) return true;
    return false;
}

int main() {
    scanf("%d %d %d", &N, &M, &K);

    for(int i = 0; i < N; i++) {
        scanf("\n");
        for(int j = 0; j < M; j++) {
            scanf("%c", &G[i][j]);
        }
    }

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            if(i == 0 || G[i - 1][j] != G[i][j]) Y.push_back(i);
            if(j == 0 || G[i][j - 1] != G[i][j]) X.push_back(j);
        }
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    X.resize(unique(X.begin(), X.end()) - X.begin());
    Y.resize(unique(Y.begin(), Y.end()) - Y.begin());
    Xn = X.size();
    Yn = Y.size();
    X.push_back(M);
    Y.push_back(N);

    for(int i = 0; i < Yn; i++) {
        for(int j = 0; j < Xn; j++) {
            T[i][j] = G[ Y[i] ][ X[j] ];
        }
    }

    psum = rsum = csum = vector<vector<int> >(Yn, vector<int>(Xn, 0));
    for(int i = 0; i < Yn; i++) {
        for(int j = 0; j < Xn; j++) {
            if(T[i][j] == '.') continue;
            psum[i][j] = 2;
            if((i && T[i - 1][j] == '*') || (j && T[i][j - 1] == '*')) psum[i][j]--;
            if((i != Yn - 1 && T[i + 1][j] == '*') || (j != Xn - 1 && T[i][j + 1] == '*')) psum[i][j]--;

            rsum[i][j] = 1;
            csum[i][j] = 1;
            if(i == 0 || T[i - 1][j] == '.') rsum[i][j] = 0;
            if(j == 0 || T[i][j - 1] == '.') csum[i][j] = 0;
        }
    }
    prop(psum);
    prop(rsum);
    prop(csum);

    ll ans = 0;
    for(int i = 0; i < Yn; i++) {
        for(int j = i; j < Yn; j++) {
            for(int a = 0; a < Xn; a++) {
                int t = Y[i + 1] - Y[i];
                int d = Y[j + 1] - Y[j];
                int l = calc(i, a, j, a, psum)? 1 : X[a + 1] - X[a];
                int r;

                for(int b = a; b < Xn; b++) {
                    if(T[i][b] == '*') t = 1;
                    if(T[j][b] == '*') d = 1;

                    if(cross(i, a, j, b)) continue;
                    int tmp = calc(i, a, j, b, psum) / 2;

                    if(1 <= tmp && tmp <= 3) {
                        //cout << i << ' ' << a << ' ' << j << ' ' << b << ' ' << tmp << endl;

                        r = calc(i, b, j, b, psum)? 1 : X[b + 1] - X[b];
                        ans += 1LL * t * d * l * r;
                    }
                }
            }
        }
    }
    printf("%lld", ans);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int N, M, K, Xn, Yn;
char G[1010][1010], T[200][200];
vector<int> X, Y;
vector<vector<int> > psum, rsum, csum;

void prop(vector<vector<int> > &psum) {
    for(int i = 0; i < Yn; i++) {
        for(int j = 0; j < Xn; j++) {
            if(i) psum[i][j] += psum[i - 1][j];
            if(j) psum[i][j] += psum[i][j - 1];
            if(i && j) psum[i][j] -= psum[i - 1][j - 1];
        }
    }
}

int calc(int r1, int c1, int r2, int c2, vector<vector<int> > &psum) {
    int ret = psum[r2][c2];
    if(r1) ret -= psum[r1 - 1][c2];
    if(c1) ret -= psum[r2][c1 - 1];
    if(r1 && c1) ret += psum[r1 - 1][c1 - 1];
    return ret;
}

bool cross(int r1, int c1, int r2, int c2) {
    if(calc(r1, c1, r1, c2, rsum)) return true;
    if(calc(r1, c1, r2, c1, csum)) return true;
    if(r2 < Yn - 1 && calc(r2 + 1, c1, r2 + 1, c2, rsum)) return true;
    if(c2 < Xn - 1 && calc(r1, c2 + 1, r2, c2 + 1, csum)) return true;
    return false;
}

int main() {
    scanf("%d %d %d", &N, &M, &K);

    for(int i = 0; i < N; i++) {
        scanf("\n");
        for(int j = 0; j < M; j++) {
            scanf("%c", &G[i][j]);
        }
    }

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            if(i == 0 || G[i - 1][j] != G[i][j]) Y.push_back(i);
            if(j == 0 || G[i][j - 1] != G[i][j]) X.push_back(j);
        }
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    X.resize(unique(X.begin(), X.end()) - X.begin());
    Y.resize(unique(Y.begin(), Y.end()) - Y.begin());
    Xn = X.size();
    Yn = Y.size();
    X.push_back(M);
    Y.push_back(N);

    for(int i = 0; i < Yn; i++) {
        for(int j = 0; j < Xn; j++) {
            T[i][j] = G[ Y[i] ][ X[j] ];
        }
    }

    psum = rsum = csum = vector<vector<int> >(Yn, vector<int>(Xn, 0));
    for(int i = 0; i < Yn; i++) {
        for(int j = 0; j < Xn; j++) {
            if(T[i][j] == '.') continue;
            psum[i][j] = 2;
            if((i && T[i - 1][j] == '*') || (j && T[i][j - 1] == '*')) psum[i][j]--;
            if((i != Yn - 1 && T[i + 1][j] == '*') || (j != Xn - 1 && T[i][j + 1] == '*')) psum[i][j]--;

            rsum[i][j] = 1;
            csum[i][j] = 1;
            if(i == 0 || T[i - 1][j] == '.') rsum[i][j] = 0;
            if(j == 0 || T[i][j - 1] == '.') csum[i][j] = 0;
        }
    }
    prop(psum);
    prop(rsum);
    prop(csum);

    ll ans = 0;
    for(int i = 0; i < Yn; i++) {
        for(int j = i; j < Yn; j++) {
            for(int a = 0; a < Xn; a++) {
                for(int b = a; b < Xn; b++) {
                    if(cross(i, a, j, b)) continue;
                    int tmp = calc(i, a, j, b, psum) / 2;

                    if(1 <= tmp && tmp <= 3) {
                        //cout << i << ' ' << a << ' ' << j << ' ' << b << ' ' << tmp << endl;

                        int t = calc(i, a, i, b, psum)? 1 : Y[i + 1] - Y[i];
                        int d = calc(j, a, j, b, psum)? 1 : Y[j + 1] - Y[j];
                        int l = calc(i, a, j, a, psum)? 1 : X[a + 1] - X[a];
                        int r = calc(i, b, j, b, psum)? 1 : X[b + 1] - X[b];

                        ans += 1LL * t * d * l * r;
                    }
                }
            }
        }
    }
    printf("%lld", ans);
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#define mk make_pair
#define pb push_back
using namespace std;
struct ppp{
 int x1,x2,y1,y2;
 void mk(int x1_,int x2_,int y1_,int y2_){
  x1=x1_; x2=x2_; y1=y1_; y2=y2_;
 }
}a[120];
long long ans;
int n,m,i,j,k,x,y,l,r,P[220],tot,Pn,u,d;
char c[1010][1010];
int Find(int x){
 return lower_bound(P+1,P+Pn+1,x)-P;
}
int main(){
 scanf("%d%d%*d",&n,&m);
 for(i=1;i<=n;++i)scanf("%s",c[i]+1);
 for(i=1;i<=n;++i)
  for(j=1;j<=m;++j)if(c[i][j]=='*'){
   k=j;
   while(c[i][k]=='*')k++; k--;
   l=i;
   while(c[l][j]=='*')l++; l--;
   for(x=i;x<=l;++x)
    for(y=j;y<=k;++y)c[x][y]='.';
   a[++tot].mk(i,l,j,k);
   P[++Pn]=i; P[++Pn]=l;
  }
 P[++Pn]=0; P[++Pn]=n+1;
 sort(P+1,P+Pn+1);
 Pn=unique(P+1,P+Pn+1)-P-1;
 for(i=1;i<=tot;++i)a[i].x1=Find(a[i].x1),a[i].x2=Find(a[i].x2);
 for(u=2;u<Pn;++u){
  for(d=u;d<Pn;++d){
   long long tmp=0;
   vector<pair<int,int> >Q;
   for(i=1;i<=tot;++i){
    if(a[i].x2<u || a[i].x1>d)continue;
    if(a[i].x1>=u && a[i].x2<=d)Q.pb(mk(a[i].y1,-1)),Q.pb(mk(a[i].y2,1));
    else Q.pb(mk(a[i].y1,-100)),Q.pb(mk(a[i].y2,100));
   }
   sort(Q.begin(),Q.end());
   int num=Q.size(),C,suml,sumr,cc;
   Q.push_back(mk(m+1,0));
   for(int C=1;C<=3;++C){
    suml=sumr=0; cc=0;
    for(l=0,r=0;r<num;++r){
     sumr+=Q[r].second;
     cc+=max(0,Q[r].second);
     if(!sumr){
      while(suml || cc>C){
       suml-=Q[l].second;
       cc-=max(0,Q[l].second);
       l++;
      }
      if(!suml && cc==C)tmp+=(Q[r+1].first-Q[r].first)*(Q[l].first-(!l?0:Q[l-1].first));
     }
    }
   }
   ans+=tmp*(P[u]-P[u-1])*(P[d+1]-P[d]);
  }
 }
 printf("%I64d\n",ans);
}


#include <bits/stdc++.h>

#define all(a) (a).begin(), (a).end()
#define pb push_back
#define sz(a) (int)(a).size()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double ld;

const int nmax = 1050;

char a[nmax][nmax];
int h, w;
char used[nmax][nmax];

struct rect {
    int xmin, xmax;
    int ymin, ymax;
    bool operator<(const rect& other) const {
        return ymin < other.ymin;
    }
};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};

void dfs(int i, int j, int& xmin, int& xmax, int& ymin, int& ymax) {
    xmin = min(xmin, i);
    xmax = max(xmax, i);
    ymin = min(ymin, j);
    ymax = max(ymax, j);
    used[i][j] = true;
    for (int k = 0; k < 4; ++k) {
        int x = i + dx[k], y = j + dy[k];
        if (x < 0 || x >= h || y < 0 || y >= w || a[x][y] == '.' || used[x][y]) {
            continue;
        }
        dfs(x, y, xmin, xmax, ymin, ymax);
    }
}

int main() {

    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int k;
    cin >> h >> w >> k;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
        }
    }

    memset(used, false, sizeof(used));
    vector<rect> v;
    vector<int> lst;
    lst.pb(h - 1);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (used[i][j] || a[i][j] == '.') {
                continue;
            }
            int xmin = i, xmax = i;
            int ymin = j, ymax = j;
            dfs(i, j, xmin, xmax, ymin, ymax);
            v.pb({xmin, xmax, ymin, ymax});
            if (xmin > 0) {
                lst.pb(xmin - 1);
            }
            lst.pb(xmin);
            if (xmax > 0) {
                lst.pb(xmax - 1);
            }
            lst.pb(xmax);
        }
    }

    for (int i = 0; i < h; ++i) {
        lst.pb(i);
    }

    assert(sz(v) == k);
    sort(all(lst));
    lst.resize(unique(all(lst)) - lst.begin());
    vector<pii> segs;
    int pr = 0;
    for (int i = 0; i < sz(lst); ++i) {
        segs.pb({pr, lst[i]});
        pr = lst[i] + 1;
    }

    ll ans = 0;

    for (int a = 0; a < sz(segs); ++a) {
        for (int b = a; b < sz(segs); ++b) {
            //ll oldAns = ans;
            vector<rect> alive;
            for (int i = 0; i < k; ++i) {
                if (v[i].xmax < segs[a].first || v[i].xmin > segs[b].second) {
                    continue;
                }
                alive.pb(v[i]);
            }
            sort(all(alive));
            vector<ll> dp(4, 0);
            ll x = segs[a].second - segs[a].first + 1;
            ll y = segs[b].second - segs[b].first + 1;
            int ptr = 0;
            int curr = 0;
            /*if (a == 0 && b == 9) {
                cout << ans << "\n";
            }*/
            while (ptr < sz(alive)) {
                /*if (a == 0 && b == 9) {
                    cout << curr << " " << ptr << " " << alive[ptr].ymin << "\n";
                }*/
                if (curr < alive[ptr].ymin) {
                    for (int j = 1; j <= 3; ++j) {
                        ans += dp[j] * ll(alive[ptr].ymin - curr);
                    }
                    dp[0] += ll(alive[ptr].ymin - curr) * (a == b ? x * (x + 1) / 2 : x * y);
                    curr = alive[ptr].ymin;
                }
                assert(curr == alive[ptr].ymin);
                int nx = ptr;
                int rg = alive[ptr].ymax;
                while (nx + 1 < sz(alive) && alive[nx + 1].ymin <= rg) {
                    ++nx;
                    rg = max(rg, alive[nx].ymax);
                }
                /*if (a == 0 && b == 9) {
                    cout << ptr << " " << nx << "\n";
                }*/
                bool ok = true;
                for (int j = ptr; j <= nx; ++j) {
                    if (alive[j].xmax > segs[b].second || alive[j].xmin < segs[a].second) {
                        ok = false;
                        break;
                    }
                }
                if (!ok) {
                    dp.assign(4, 0);
                    ptr = nx + 1;
                    curr = rg + 1;
                    continue;
                }
                /*if (a == 0 && b == 9 && ptr == 4) {
                    for (int j = 0; j < 4; ++j) {
                        cout << dp[j] << " ";
                    }
                    cout << "\n";
                }*/
                vector<ll> dpNew(4, 0);
                for (int j = 0; j < 4; ++j) {
                    if (j + (nx - ptr + 1) < 4) {
                        dpNew[j + (nx - ptr + 1)] = dp[j];
                    }
                }
                if (nx - ptr + 1 < 4) {
                    dpNew[nx - ptr + 1] += (a == b ? x * (x + 1) / 2 : x * y);
                }
                dp.swap(dpNew);
                for (int j = 1; j <= 3; ++j) {
                    ans += dp[j];
                }
                ptr = nx + 1;
                curr = rg + 1;
                /*if (a == 0 && b == 9) {
                    cout << ans << "\n";
                }*/
            }
            if (curr < w) {
                for (int j = 1; j <= 3; ++j) {
                    ans += dp[j] * ll(w - curr);
                }
            }
            /*if (a == 0 && b == 9) {
                cout << ans << "\n";
            }*/
            //cout << segs[a].first << " " << segs[b].first << " " << ans - oldAns << "\n";
        }
    }

    cout << ans << "\n";

}


#include <bits/stdc++.h>

#define all(a) (a).begin(), (a).end()
#define pb push_back
#define sz(a) (int)(a).size()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double ld;

const int nmax = 1050;

char a[nmax][nmax];
int h, w;
char used[nmax][nmax];

struct rect {
    int xmin, xmax;
    int ymin, ymax;
    bool operator<(const rect& other) const {
        return ymin < other.ymin;
    }
};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};

void dfs(int i, int j, int& xmin, int& xmax, int& ymin, int& ymax) {
    xmin = min(xmin, i);
    xmax = max(xmax, i);
    ymin = min(ymin, j);
    ymax = max(ymax, j);
    used[i][j] = true;
    for (int k = 0; k < 4; ++k) {
        int x = i + dx[k], y = j + dy[k];
        if (x < 0 || x >= h || y < 0 || y >= w || a[x][y] == '.' || used[x][y]) {
            continue;
        }
        dfs(x, y, xmin, xmax, ymin, ymax);
    }
}

int main() {

    //ifstream cin("input.txt");
    //ofstream cout("input.txt");
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int k;
    cin >> h >> w >> k;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
        }
    }

    memset(used, false, sizeof(used));
    vector<rect> v;
    vector<int> lst;
    lst.pb(h - 1);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (used[i][j] || a[i][j] == '.') {
                continue;
            }
            int xmin = i, xmax = i;
            int ymin = j, ymax = j;
            dfs(i, j, xmin, xmax, ymin, ymax);
            v.pb({xmin, xmax, ymin, ymax});
            if (xmin > 0) {
                lst.pb(xmin - 1);
            }
            lst.pb(xmin);
            if (xmax > 0) {
                lst.pb(xmax - 1);
            }
            lst.pb(xmax);
        }
    }

    assert(sz(v) == k);
    sort(all(lst));
    lst.resize(unique(all(lst)) - lst.begin());
    vector<pii> segs;
    int pr = 0;
    for (int i = 0; i < sz(lst); ++i) {
        segs.pb({pr, lst[i]});
        pr = lst[i] + 1;
    }

    ll ans = 0;

    for (int a = 0; a < sz(segs); ++a) {
        for (int b = a; b < sz(segs); ++b) {
            vector<rect> alive;
            for (int i = 0; i < k; ++i) {
                if (v[i].xmax < segs[a].first || v[i].xmin > segs[b].second) {
                    continue;
                }
                alive.pb(v[i]);
            }
            sort(all(alive));
            vector<ll> dp(4, 0);
            ll x = segs[a].second - segs[a].first + 1;
            ll y = segs[b].second - segs[b].first + 1;
            int ptr = 0;
            int curr = 0;
            while (ptr < sz(alive)) {
                if (curr < alive[ptr].ymin) {
                    for (int j = 1; j <= 3; ++j) {
                        ans += dp[j] * ll(alive[ptr].ymin - curr);
                    }
                    dp[0] += ll(alive[ptr].ymin - curr) * (a == b ? x * (x + 1) / 2 : x * y);
                    curr = alive[ptr].ymin;
                }
                int nx = ptr;
                int rg = alive[ptr].ymax;
                while (nx + 1 < sz(alive) && alive[nx + 1].ymin <= rg) {
                    ++nx;
                    rg = max(rg, alive[nx].ymax);
                }
                /*if (a == 0 && b == 2) {
                    cout << ptr << " " << nx << "\n";
                }*/
                bool ok = true;
                for (int j = ptr; j <= nx; ++j) {
                    if (alive[j].xmax > segs[b].second || alive[j].xmin < segs[a].second) {
                        ok = false;
                        break;
                    }
                }
                if (!ok) {
                    dp.assign(4, 0);
                    ptr = nx + 1;
                    curr = alive[nx].ymax + 1;
                    continue;
                }
                vector<ll> dpNew(4, 0);
                for (int j = 0; j < 4; ++j) {
                    if (j + (nx - ptr + 1) < 4) {
                        dpNew[j + (nx - ptr + 1)] = dp[j];
                    }
                }
                if (nx - ptr + 1 < 4) {
                    dpNew[nx - ptr + 1] += (a == b ? x * (x + 1) / 2 : x * y);
                }
                dp.swap(dpNew);
                for (int j = 1; j <= 3; ++j) {
                    ans += dp[j];
                }
                ptr = nx + 1;
                curr = alive[nx].ymax + 1;
            }
            if (curr < w) {
                for (int j = 1; j <= 3; ++j) {
                    ans += dp[j] * ll(w - curr);
                }
            }
            //cout << segs[a].first << " " << segs[a].second << " " << segs[b].first << " " << segs[b].second << " " << ans << "\n";
        }
    }

    cout << ans << "\n";

}


#include <bits/stdc++.h>

#define all(a) (a).begin(), (a).end()
#define pb push_back
#define sz(a) (int)(a).size()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double ld;

const int nmax = 1050;

char a[nmax][nmax];
int h, w;
char used[nmax][nmax];

struct rect {
    int xmin, xmax;
    int ymin, ymax;
    bool operator<(const rect& other) const {
        return ymin < other.ymin;
    }
};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};

void dfs(int i, int j, int& xmin, int& xmax, int& ymin, int& ymax) {
    xmin = min(xmin, i);
    xmax = max(xmax, i);
    ymin = min(ymin, j);
    ymax = max(ymax, j);
    used[i][j] = true;
    for (int k = 0; k < 4; ++k) {
        int x = i + dx[k], y = j + dy[k];
        if (x < 0 || x >= h || y < 0 || y >= w || a[x][y] == '.' || used[x][y]) {
            continue;
        }
        dfs(x, y, xmin, xmax, ymin, ymax);
    }
}

int main() {

    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int k;
    cin >> h >> w >> k;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
        }
    }

    memset(used, false, sizeof(used));
    vector<rect> v;
    vector<int> lst;
    lst.pb(h - 1);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (used[i][j] || a[i][j] == '.') {
                continue;
            }
            int xmin = i, xmax = i;
            int ymin = j, ymax = j;
            dfs(i, j, xmin, xmax, ymin, ymax);
            v.pb({xmin, xmax, ymin, ymax});
            if (xmin > 0) {
                lst.pb(xmin - 1);
            }
            lst.pb(xmin);
            if (xmax > 0) {
                lst.pb(xmax - 1);
            }
            lst.pb(xmax);
        }
    }

    /*for (int i = 0; i < h; ++i) {
        lst.pb(i);
    }*/

    assert(sz(v) == k);
    sort(all(lst));
    lst.resize(unique(all(lst)) - lst.begin());
    vector<pii> segs;
    int pr = 0;
    for (int i = 0; i < sz(lst); ++i) {
        segs.pb({pr, lst[i]});
        pr = lst[i] + 1;
    }

    ll ans = 0;

    for (int a = 0; a < sz(segs); ++a) {
        for (int b = a; b < sz(segs); ++b) {
            //ll oldAns = ans;
            vector<rect> alive;
            for (int i = 0; i < k; ++i) {
                if (v[i].xmax < segs[a].first || v[i].xmin > segs[b].second) {
                    continue;
                }
                alive.pb(v[i]);
            }
            sort(all(alive));
            vector<ll> dp(4, 0);
            ll x = segs[a].second - segs[a].first + 1;
            ll y = segs[b].second - segs[b].first + 1;
            int ptr = 0;
            int curr = 0;
            /*if (a == 0 && b == 9) {
                cout << ans << "\n";
            }*/
            while (ptr < sz(alive)) {
                /*if (a == 0 && b == 9) {
                    cout << curr << " " << ptr << " " << alive[ptr].ymin << "\n";
                }*/
                if (curr < alive[ptr].ymin) {
                    for (int j = 1; j <= 3; ++j) {
                        ans += dp[j] * ll(alive[ptr].ymin - curr);
                    }
                    dp[0] += ll(alive[ptr].ymin - curr) * (a == b ? x * (x + 1) / 2 : x * y);
                    curr = alive[ptr].ymin;
                }
                assert(curr == alive[ptr].ymin);
                int nx = ptr;
                int rg = alive[ptr].ymax;
                while (nx + 1 < sz(alive) && alive[nx + 1].ymin <= rg) {
                    ++nx;
                    rg = max(rg, alive[nx].ymax);
                }
                /*if (a == 0 && b == 9) {
                    cout << ptr << " " << nx << "\n";
                }*/
                bool ok = true;
                for (int j = ptr; j <= nx; ++j) {
                    if (alive[j].xmax > segs[b].second || alive[j].xmin < segs[a].second) {
                        ok = false;
                        break;
                    }
                }
                if (!ok) {
                    dp.assign(4, 0);
                    ptr = nx + 1;
                    curr = rg + 1;
                    continue;
                }
                /*if (a == 0 && b == 9 && ptr == 4) {
                    for (int j = 0; j < 4; ++j) {
                        cout << dp[j] << " ";
                    }
                    cout << "\n";
                }*/
                vector<ll> dpNew(4, 0);
                for (int j = 0; j < 4; ++j) {
                    if (j + (nx - ptr + 1) < 4) {
                        dpNew[j + (nx - ptr + 1)] = dp[j];
                    }
                }
                if (nx - ptr + 1 < 4) {
                    dpNew[nx - ptr + 1] += (a == b ? x * (x + 1) / 2 : x * y);
                }
                dp.swap(dpNew);
                for (int j = 1; j <= 3; ++j) {
                    ans += dp[j];
                }
                ptr = nx + 1;
                curr = rg + 1;
                /*if (a == 0 && b == 9) {
                    cout << ans << "\n";
                }*/
            }
            if (curr < w) {
                for (int j = 1; j <= 3; ++j) {
                    ans += dp[j] * ll(w - curr);
                }
            }
            /*if (a == 0 && b == 9) {
                cout << ans << "\n";
            }*/
            //cout << segs[a].first << " " << segs[b].first << " " << ans - oldAns << "\n";
        }
    }

    cout << ans << "\n";

}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define mk make_pair
#define pb push_back
using namespace std;
struct ppp {
  int x1, x2, y1, y2;
  void mk(int x1_, int x2_, int y1_, int y2_) {
    x1 = x1_;
    x2 = x2_;
    y1 = y1_;
    y2 = y2_;
  }
} a[120];
long long ans;
int n, m, i, j, k, x, y, l, r, P[220], tot, Pn, u, d;
char c[1010][1010];
int Find(int x) { return lower_bound(P + 1, P + Pn + 1, x) - P; }
int main() {
  scanf("%d%d%*d", &n, &m);
  for (i = 1; i <= n; ++i) scanf("%s", c[i] + 1);
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j)
      if (c[i][j] == '*') {
        k = j;
        while (c[i][k] == '*') k++;
        k--;
        l = i;
        while (c[l][j] == '*') l++;
        l--;
        for (x = i; x <= l; ++x)
          for (y = j; y <= k; ++y) c[x][y] = '.';
        a[++tot].mk(i, l, j, k);
        P[++Pn] = i;
        P[++Pn] = l;
      }
  P[++Pn] = 0;
  P[++Pn] = n + 1;
  sort(P + 1, P + Pn + 1);
  Pn = unique(P + 1, P + Pn + 1) - P - 1;
  for (i = 1; i <= tot; ++i) a[i].x1 = Find(a[i].x1), a[i].x2 = Find(a[i].x2);
  for (u = 2; u < Pn; ++u) {
    for (d = u; d < Pn; ++d) {
      long long tmp = 0;
      vector<pair<int, int> > Q;
      for (i = 1; i <= tot; ++i) {
        if (a[i].x2 < u || a[i].x1 > d) continue;
        if (a[i].x1 >= u && a[i].x2 <= d)
          Q.pb(mk(a[i].y1, -1)), Q.pb(mk(a[i].y2, 1));
        else
          Q.pb(mk(a[i].y1, -100)), Q.pb(mk(a[i].y2, 100));
      }
      sort(Q.begin(), Q.end());
      int num = Q.size(), C, suml, sumr, cc;
      Q.push_back(mk(m + 1, 0));
      for (int C = 1; C <= 3; ++C) {
        suml = sumr = 0;
        cc = 0;
        for (l = 0, r = 0; r < num; ++r) {
          sumr += Q[r].second;
          cc += max(0, Q[r].second);
          if (!sumr) {
            while (suml || cc > C) {
              suml -= Q[l].second;
              cc -= max(0, Q[l].second);
              l++;
            }
            if (!suml && cc == C)
              tmp += (Q[r + 1].first - Q[r].first) *
                     (Q[l].first - (!l ? 0 : Q[l - 1].first));
          }
        }
      }
      ans += tmp * (P[u] - P[u - 1]) * (P[d + 1] - P[d]);
    }
  }
  printf("%I64d\n", ans);
}


#include <iostream>
#include <string.h>
#include <string>
#include <cstring>
#include <vector>
#pragma comment (linker, "/STACK:256000000")

using namespace std;

int n, m, t;
int xl[100], yl[100], xr[100], yr[100], nt, area[100];
char s[1100][1100];
int lt[1100][1100];
int up[1100][1100];
int dw[1100][1100];
int p[1100][1100];

int dx[] = {-1, 0, 0, 1};
int dy[] = { 0,-1, 1, 0};

bool used[1100][1100];

bool val(int x, int y) {return (0 <= x && x < n && 0 <= y && y < m);}

void dfs(int x, int y)
{
	if (used[x][y]) return ;
	used[x][y] = true;
	xl[nt] = min(x, xl[nt]), xr[nt] = max(x, xr[nt]);
	yl[nt] = min(y, yl[nt]), yr[nt] = max(y, yr[nt]);

	for (int i = 0; i < 4; i ++)
		if (val(x + dx[i], y + dy[i]) && s[x + dx[i]][y + dy[i]] == '*')
			dfs(x + dx[i], y + dy[i]);
}

int sum(int x, int y)
{
	if (x < 0 || y < 0) return 0;
	return p[x][y];
}

int sum(int x1, int y1, int x2, int y2)
{
	return p[x2][y2] - sum(x1 - 1, y2) - sum(x2, y1 - 1) + sum(x1 - 1, y1 - 1);
}

int nl[1100], nr[1100];
int a[1100];

int levo[1100], pravo[1100];
int ml[1100], mr[1100];
int sl[1100], sr[1100];

int getsum(int i, int r)
{
	if (r <= ml[i])
		return (r + 1) * levo[i];
	return (ml[i] + 1) * levo[i] + sr[r] - sr[ml[i]];
}

int getsum2(int i, int r)
{
	if (r <= mr[i])
		return (r + 1) * pravo[i];
	return (mr[i] + 1) * pravo[i] + sl[r] - sl[mr[i]];
}

long long solve(int x1, int y1, int x2, int y2)
{
	int segs = 0;
	if (y1 == 0)
	{
		//segs ++; nl[segs] = x1, nr[segs] = x2;
	} else
	{
		int sl = x1 - 1, sr = x2 + 1;
		int f = y2 - y1 + 1;
		while (sl >= 0)
		{
			if (lt[sl][y1 - 1] >= f + 1 && s[sl][y1 - 1] == '.') sl --; else break;
		}
		sl ++;
		while (sr < n)
		{
			if (lt[sr][y1 - 1] >= f + 1 && s[sr][y1 - 1] == '.') sr ++; else break;
		}
		sr --;
		if (up[sr][y1 - 1] >= sr - sl + 1)
		{
			segs ++;
			nl[segs] = sl, nr[segs] = sr;
			for (int i = y1 - 2; i >= 0; i --)
			{
				int L = x1 - up[x1][i] + 1, R = x1 + dw[x1][i] - 1;
				if (L > x1 || R < x2) break;
				sl = max(sl, L), sr = min(sr, R);
				segs ++;
				nl[segs] = sl, nr[segs] = sr;
			}
		}
		//segs ++;
		//nl[segs] = x1, nr[segs] = x2;
	}

	int s1 = nl[1], s2 = nr[1];
	for (int i = s1; i <= s2; i ++)
		a[i] = lt[i][y2 + 1] + 1;

	int mn = 1000000;
	for (int i = x1; i <= x2; i ++)
		mn = min(mn, a[i]);

	int l1 = x1 - s1, l2 = s2 - x2;
	levo[0] = pravo[0] = mn;
	for (int i = 1; i <= l1; i ++)
		levo[i] = min(levo[i - 1], lt[x1 - i][y2 + 1] + 1);
	for (int i = 1; i <= l2; i ++)
		pravo[i] = min(pravo[i - 1], lt[x2 + i][y2 + 1] + 1);

	int v;
	v = 1;
	for (int i = 1; i <= l1; i ++)
	{
		while (v <= l2 && pravo[v] >= levo[i])
			v ++;
		ml[i] = v - 1;
	}
	v = 1;
	for (int i = 1; i <= l2; i ++)
	{
		while (v <= l1 && levo[v] >= pravo[i])
			v ++;
		mr[i] = v - 1;
	}

	sl[0] = sr[0] = mn;
	for (int i = 1; i <= l1; i ++)
		sl[i] = sl[i - 1] + levo[i];
	for (int i = 1; i <= l2; i ++)
		sr[i] = sr[i - 1] + pravo[i];

	long long res = 0;
	int cur = 0;
	for (int h = 1; h <= segs; h ++)
		if (h == 1)
		{
			//cur += sr[l2] + mn;
			for (int i = 0; i <= l1; i ++)
				cur += (ml[i] + 1) * levo[i] + (sr[l2] - sr[ml[i]]);
			res += (long long)(cur);
		} else
		{
			for (int i = nl[h - 1]; i < nl[h]; i ++)
				cur -= getsum(x1 - i, nr[h - 1] - x2);
			for (int i = nr[h - 1]; i > nr[h]; i --)
				cur -= getsum2(i - x2, x1 - nl[h]);
			res += (long long)(cur);
		}

	int mup = 1000000, mdw = 1000000;
	for (int i = y1; i <= y2; i ++)
	{
		if (x1 == 0) mup = 0; else
			mup = min(mup, up[x1 - 1][i]);
		if (x2 == n - 1) mdw = 0; else
			mdw = min(mdw, dw[x2 + 1][i]);
	}
	s1 = x1 - mup, s2 = x2 + mdw;
	mn = 1000000;
	for (int i = s1; i <= s2; i ++)
		a[i] = lt[i][y2 + 1] + 1;
	for (int i = x1; i <= x2; i ++)
		mn = min(mn, a[i]);

	l1 = x1 - s1, l2 = s2 - x2;
	levo[0] = pravo[0] = mn;
	for (int i = 1; i <= l1; i ++)
		levo[i] = min(levo[i - 1], lt[x1 - i][y2 + 1] + 1);
	for (int i = 1; i <= l2; i ++)
		pravo[i] = min(pravo[i - 1], lt[x2 + i][y2 + 1] + 1);

	v = 1;
	for (int i = 1; i <= l1; i ++)
	{
		while (v <= l2 && pravo[v] >= levo[i])
			v ++;
		ml[i] = v - 1;
	}
	v = 1;
	for (int i = 1; i <= l2; i ++)
	{
		while (v <= l1 && levo[v] >= pravo[i])
			v ++;
		mr[i] = v - 1;
	}

	sl[0] = sr[0] = mn;
	for (int i = 1; i <= l1; i ++)
		sl[i] = sl[i - 1] + levo[i];
	for (int i = 1; i <= l2; i ++)
		sr[i] = sr[i - 1] + pravo[i];

	//cur = sr[l2] + mn;
	cur = 0;
	for (int i = 0; i <= l1; i ++)
		cur += (ml[i] + 1) * levo[i] + (sr[l2] - sr[ml[i]]);
	res += (long long)(cur);

	return res;
}

void precalc()
{
	for (int i = 0; i < n; i ++)
	{
		lt[i][m - 1] = (s[i][m - 1] == '*' ? 0 : 1);
		for (int j = m - 2; j >= 0; j --)
			if (s[i][j] == '*') lt[i][j] = 0; else lt[i][j] = lt[i][j + 1] + 1;
	}

	for (int j = 0; j < m; j ++)
	{
		up[0][j] = (s[0][j] == '*' ? 0 : 1);
		for (int i = 1; i < n; i ++)
			if (s[i][j] == '*') up[i][j] = 0; else up[i][j] = up[i - 1][j] + 1;
	}

	for (int j = 0; j < m; j ++)
	{
		dw[n - 1][j] = (s[n - 1][j] == '*' ? 0 : 1);
		for (int i = n - 2; i >= 0; i --)
			if (s[i][j] == '*') dw[i][j] = 0; else dw[i][j] = dw[i + 1][j] + 1;
	}
}

int check(int x1, int y1, int x2, int y2)
{
	int res = 0;
	for (int i = 0; i <= x1; i ++)
		for (int j = 0; j <= y1; j ++)
			for (int k = x2; k < n; k ++)
				for (int l = y2; l < m; l ++)
					if (sum(i, j, k, l) == sum(x1, y1, x2, y2)) res ++;
	return res;
}

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	scanf("%d%d%d\n", &n, &m, &t);
	for (int i = 0; i < n; i ++)
		gets(s[i]);

	for (int i = 0; i < n; i ++)
		for (int j = 0; j < m; j ++)
			if (!used[i][j] && s[i][j] == '*')
			{
				nt ++;
				xl[nt] = yl[nt] = 1000000;
				xr[nt] = yr[nt] = 0;
				dfs(i, j);
				area[nt] = (xr[nt] - xl[nt] + 1) * (yr[nt] - yl[nt] + 1);
			}

	p[0][0] = (s[0][0] == '*' ? 1 : 0);
	for (int i = 1; i < m; i ++)
		p[0][i] = p[0][i - 1] + (s[0][i] == '*' ? 1 : 0);
	for (int i = 1; i < n; i ++)
		p[i][0] = p[i - 1][0] + (s[i][0] == '*' ? 1 : 0);
	for (int i = 1; i < n; i ++)
		for (int j = 1; j < m; j ++)
			p[i][j] = (p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1]) + (s[i][j] == '*' ? 1 : 0);

	t = nt;

	precalc();

	long long res = 0, cur = 0;
	for (int i = 1; i <= t; i ++)
		res += solve(xl[i], yl[i], xr[i], yr[i]);
		//cur += check(xl[i], yl[i], xr[i], yr[i]);
	for (int i = 1; i <= t; i ++)
		for (int j = i + 1; j <= t; j ++)
		{
			int x1 = xl[i], y1 = yl[i], x2 = xr[i], y2 = yr[i];
			x1 = min(x1, xl[j]), y1 = min(y1, yl[j]);
			x2 = max(x2, xr[j]), y2 = max(y2, yr[j]);
			if (sum(x1, y1, x2, y2) == area[i] + area[j])
				res += solve(x1, y1, x2, y2);
				//cur += check(x1, y1, x2, y2);
		}

	for (int i = 1; i <= t; i ++)
		for (int j = i + 1; j <= t; j ++)
			for (int k = j + 1; k <= t; k ++)
			{
				int x1 = xl[i], y1 = yl[i], x2 = xr[i], y2 = yr[i];
				x1 = min(x1, xl[j]), y1 = min(y1, yl[j]);
				x2 = max(x2, xr[j]), y2 = max(y2, yr[j]);
				x1 = min(x1, xl[k]), y1 = min(y1, yl[k]);
				x2 = max(x2, xr[k]), y2 = max(y2, yr[k]);
				if (sum(x1, y1, x2, y2) == area[i] + area[j] + area[k])
					res += solve(x1, y1, x2, y2);
					//cur += check(x1, y1, x2, y2);
			}

	cout << res << endl;
	//cout << cur << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
const int inf=1e9;
int xx[400],yy[400];
int cnt_x,cnt_y;
struct rectangle
{
	int lx,ly,rx,ry;
};
rectangle rec[99];
int n,m,k,cnt,mc[1111][1111],list[99],cnt_list;
long long ans,now;
char str[1111][1111];
int main()
{
	int i,j,s,p,q,id;
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++)
	   scanf("%s",str[i]);
    cnt=0;
	for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   if(str[i][j]=='*'&&!(i>0&&str[i-1][j]=='*')&&!(j>0&&str[i][j-1]=='*'))
       	   {
  	       	   rec[cnt].lx=i;
  	       	   rec[cnt].ly=j;
  	       	   for(s=i;s<n;s++)
  	       	   {
  	       	      for(p=j;p<m;p++)
  	       	      {
     	       	      if(str[s][p]!='*')
						  break;
     	          }
                  if(p==j)
                     break;
                  rec[cnt].ry=p-1;
  	       	   }
      	       rec[cnt++].rx=s-1;
   	       }
       }
    assert(n!=1000||m!=10000);
    memset(mc,0,sizeof(mc));
    for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   for(s=0;s<k;s++)
		   {
	           if(rec[s].lx<=i&&rec[s].ly<=j)
	                mc[i][j]++;
  		   }
       }
    cnt_x=cnt_y=0;
    xx[cnt_x++]=-1;
    yy[cnt_y++]=-1;
    for(i=0;i<k;i++)
    {
    	xx[cnt_x++]=rec[i].lx;
    	xx[cnt_x++]=rec[i].rx;
    	if(rec[i].lx-1>=0)
        	xx[cnt_x++]=rec[i].lx-1;
    	if(rec[i].rx+1<n)
 	 	    xx[cnt_x++]=rec[i].rx+1;
    	yy[cnt_y++]=rec[i].ly;
    	yy[cnt_y++]=rec[i].ry;
		if(rec[i].ly-1>=0)
     		yy[cnt_y++]=rec[i].ly-1;
		if(rec[i].ry+1<m)
		    yy[cnt_y++]=rec[i].ry+1;
    }
    sort(xx,xx+cnt_x);
    sort(yy,yy+cnt_y);
    int nn=0;
    for(i=0;i<cnt_x;i++)
    {
    	if(nn==0||xx[nn-1]<xx[i])
    	   xx[nn++]=xx[i];
    }
    cnt_x=nn;
    nn=0;
    for(i=0;i<cnt_y;i++)
    {
    	if(nn==0||yy[nn-1]<yy[i])
    	    yy[nn++]=yy[i];
    }
    cnt_y=nn;
    xx[cnt_x++]=n;
    yy[cnt_y++]=m;
	ans=0;
    for(i=1;i<cnt_x-1;i++)
       for(j=1;j<cnt_y-1;j++)
       {
       	   cnt_list=0;
           for(s=0;s<k;s++)
           {
       	       if(rec[s].rx<=xx[i]&&rec[s].ry<=yy[j])
       	           list[cnt_list++]=s;
		       else if(xx[i]>=rec[s].lx&&xx[i]<=rec[s].rx&&yy[j]>=rec[s].ly&&yy[j]<=rec[s].ry)
           	       break;
		   }
           if(s<k)
               continue;
           now=0;
           int vx,vy;
		   for(s=0;s<i;s++)
           {
           	   vy=0;
           	   for(p=0;p<j;p++)
           	   {
   	           	   int rs=mc[xx[i]][yy[j]];
       	          if(xx[s]>=0)
   	           	      rs-=mc[xx[s]][yy[j]];
        	       if(yy[p]>=0)
        	          rs-=mc[xx[i]][yy[p]];
     	           if(xx[s]>=0&&yy[p]>=0)
     	              rs+=mc[xx[s]][yy[p]];
  	               if(rs>3)
  	                  continue;
				   int qq,dy,dx;
	               dy=yy[p+1]-yy[p];
                   dx=xx[s+1]-xx[s];
                   rs=0;
				   for(qq=0;qq<cnt_list;qq++)
                   {
                   	   q=list[qq];
               	       if(xx[s]+1<=rec[q].lx&yy[p]+1<=rec[q].ly)
						  rs++;
				   }
                   if(qq>=cnt_list&&rs>=1&&rs<=3&&dx&&dy)
                   {
                   	   for(q=0;q<k;q++)
                   	   {
       	               	   if(rec[q].rx<=xx[i]&&rec[q].lx>=xx[s]+1&&rec[q].ry<=yy[j]&&rec[q].ly>=yy[p]+1)
   	                   	       continue;
                   	       else if(rec[q].rx>=xx[s]+1&&rec[q].lx<=xx[i]&&rec[q].ry>=yy[p]+1&&rec[q].ly<=yy[j])
                   	           break;
   	                   }
   	                   if(q>=k)
   	                   {
   	                   	//  if(i==1&&j==3)
   	                   	  //   printf("s=%d,p=%d,dx=%d,dy=%d,xx=%d,yy=%d\n",s,p,dx,dy,xx[s],yy[p]);
                     	   now+=(long long)dx*(long long)dy;
   	                   }
				   }
   	           }
           }
        //   printf("i=%d,j=%d,now=%I64d,xx=%d,yy=%d\n",i,j,now,xx[i],yy[j]);
           now=(long long)now*(long long)(xx[i+1]-xx[i]);
           now=(long long)now*(long long)(yy[j+1]-yy[j]);
           ans+=now;
       }
       printf("%I64d\n",ans);
	return 0;
}
/*
5 8 1
..******
..******
........
........
........

*/


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
const int inf=1e9;
int xx[400],yy[400];
int cnt_x,cnt_y;
struct rectangle
{
	int lx,ly,rx,ry;
};
rectangle rec[99];
int n,m,k,cnt,mc[1111][1111],list[99],cnt_list;
long long ans,now;
char str[1111][1111];
int main()
{
	int i,j,s,p,q,id;
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++)
	   scanf("%s",str[i]);
    cnt=0;
	for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   if(str[i][j]=='*'&&!(i>0&&str[i-1][j]=='*')&&!(j>0&&str[i][j-1]=='*'))
       	   {
  	       	   rec[cnt].lx=i;
  	       	   rec[cnt].ly=j;
  	       	   for(s=i;s<n;s++)
  	       	   {
  	       	      for(p=j;p<m;p++)
  	       	      {
     	       	      if(str[s][p]!='*')
						  break;
     	          }
                  if(p==j)
                     break;
                  rec[cnt].ry=p-1;
  	       	   }
      	       rec[cnt++].rx=s-1;
   	       }
       }
    memset(mc,0,sizeof(mc));
    for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   for(s=0;s<k;s++)
		   {
	           if(rec[s].lx<=i&&rec[s].ly<=j)
	                mc[i][j]++;
  		   }
       }
    assert(n!=1000||m!=1000);
    cnt_x=cnt_y=0;
    xx[cnt_x++]=-1;
    yy[cnt_y++]=-1;
    for(i=0;i<k;i++)
    {
    	xx[cnt_x++]=rec[i].lx;
    	xx[cnt_x++]=rec[i].rx;
    	if(rec[i].lx-1>=0)
        	xx[cnt_x++]=rec[i].lx-1;
    	if(rec[i].rx+1<n)
 	 	    xx[cnt_x++]=rec[i].rx+1;
    	yy[cnt_y++]=rec[i].ly;
    	yy[cnt_y++]=rec[i].ry;
		if(rec[i].ly-1>=0)
     		yy[cnt_y++]=rec[i].ly-1;
		if(rec[i].ry+1<m)
		    yy[cnt_y++]=rec[i].ry+1;
    }
    sort(xx,xx+cnt_x);
    sort(yy,yy+cnt_y);
    int nn=0;
    for(i=0;i<cnt_x;i++)
    {
    	if(nn==0||xx[nn-1]<xx[i])
    	   xx[nn++]=xx[i];
    }
    cnt_x=nn;
    nn=0;
    for(i=0;i<cnt_y;i++)
    {
    	if(nn==0||yy[nn-1]<yy[i])
    	    yy[nn++]=yy[i];
    }
    cnt_y=nn;
    xx[cnt_x++]=n;
    yy[cnt_y++]=m;
	ans=0;
    for(i=1;i<cnt_x-1;i++)
       for(j=1;j<cnt_y-1;j++)
       {
       	   cnt_list=0;
           for(s=0;s<k;s++)
           {
       	       if(rec[s].rx<=xx[i]&&rec[s].ry<=yy[j])
       	           list[cnt_list++]=s;
		       else if(xx[i]>=rec[s].lx&&xx[i]<=rec[s].rx&&yy[j]>=rec[s].ly&&yy[j]<=rec[s].ry)
           	       break;
		   }
           if(s<k)
               continue;
           now=0;
           int vx,vy;
		   for(s=i-1;s>=0;s--)
           {
           	   vy=0;
           	   for(p=j-1;p>=0;p--)
           	   {
   	           	   int rs=mc[xx[i]][yy[j]];
       	          if(xx[s]>=0)
   	           	      rs-=mc[xx[s]][yy[j]];
        	       if(yy[p]>=0)
        	          rs-=mc[xx[i]][yy[p]];
     	           if(xx[s]>=0&&yy[p]>=0)
     	              rs+=mc[xx[s]][yy[p]];
  	               if(rs>3)
  	                  break;
                   if(rs==0)
                       continue;
				   int qq,dy,dx;
	               dy=yy[p+1]-yy[p];
                   dx=xx[s+1]-xx[s];
                   rs=0;
				   for(qq=0;qq<cnt_list;qq++)
                   {
                   	   q=list[qq];
               	       if(xx[s]+1<=rec[q].lx&yy[p]+1<=rec[q].ly)
						  rs++;
				   }
                   if(qq>=cnt_list&&rs>=1&&rs<=3&&dx&&dy)
                   {
                   	   for(q=0;q<k;q++)
                   	   {
       	               	   if(rec[q].rx<=xx[i]&&rec[q].lx>=xx[s]+1&&rec[q].ry<=yy[j]&&rec[q].ly>=yy[p]+1)
   	                   	       continue;
                   	       else if(rec[q].rx>=xx[s]+1&&rec[q].lx<=xx[i]&&rec[q].ry>=yy[p]+1&&rec[q].ly<=yy[j])
                   	           break;
   	                   }
   	                   if(q>=k)
                     	   now+=(long long)dx*(long long)dy;
				   }
   	           }
           }
           now=(long long)now*(long long)(xx[i+1]-xx[i]);
           now=(long long)now*(long long)(yy[j+1]-yy[j]);
           ans+=now;
       }
       printf("%I64d\n",ans);
	return 0;
}
/*
5 8 1
..******
..******
........
........
........

*/


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
const int inf=1e9;
int xx[400],yy[400];
int cnt_x,cnt_y;
struct rectangle
{
	int lx,ly,rx,ry;
};
rectangle rec[99];
int n,m,k,cnt,mc[1111][1111],list[99],cnt_list;
long long ans,now;
char str[1111][1111];
int main()
{
	int i,j,s,p,q,id;
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++)
	   scanf("%s",str[i]);
    cnt=0;
	for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   if(str[i][j]=='*'&&!(i>0&&str[i-1][j]=='*')&&!(j>0&&str[i][j-1]=='*'))
       	   {
  	       	   rec[cnt].lx=i;
  	       	   rec[cnt].ly=j;
  	       	   for(s=i;s<n;s++)
  	       	   {
  	       	      for(p=j;p<m;p++)
  	       	      {
     	       	      if(str[s][p]!='*')
						  break;
     	          }
                  if(p==j)
                     break;
                  rec[cnt].ry=p-1;
  	       	   }
      	       rec[cnt++].rx=s-1;
   	       }
       }
    assert(n!=1000||m!=1000);
    memset(mc,0,sizeof(mc));
    for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   for(s=0;s<k;s++)
		   {
	           if(rec[s].lx<=i&&rec[s].ly<=j)
	                mc[i][j]++;
  		   }
       }
    cnt_x=cnt_y=0;
    xx[cnt_x++]=-1;
    yy[cnt_y++]=-1;
    for(i=0;i<k;i++)
    {
    	xx[cnt_x++]=rec[i].lx;
    	xx[cnt_x++]=rec[i].rx;
    	if(rec[i].lx-1>=0)
        	xx[cnt_x++]=rec[i].lx-1;
    	if(rec[i].rx+1<n)
 	 	    xx[cnt_x++]=rec[i].rx+1;
    	yy[cnt_y++]=rec[i].ly;
    	yy[cnt_y++]=rec[i].ry;
		if(rec[i].ly-1>=0)
     		yy[cnt_y++]=rec[i].ly-1;
		if(rec[i].ry+1<m)
		    yy[cnt_y++]=rec[i].ry+1;
    }
    sort(xx,xx+cnt_x);
    sort(yy,yy+cnt_y);
    int nn=0;
    for(i=0;i<cnt_x;i++)
    {
    	if(nn==0||xx[nn-1]<xx[i])
    	   xx[nn++]=xx[i];
    }
    cnt_x=nn;
    nn=0;
    for(i=0;i<cnt_y;i++)
    {
    	if(nn==0||yy[nn-1]<yy[i])
    	    yy[nn++]=yy[i];
    }
    cnt_y=nn;
    xx[cnt_x++]=n;
    yy[cnt_y++]=m;
	ans=0;
    for(i=1;i<cnt_x-1;i++)
       for(j=1;j<cnt_y-1;j++)
       {
       	   cnt_list=0;
           for(s=0;s<k;s++)
           {
       	       if(rec[s].rx<=xx[i]&&rec[s].ry<=yy[j])
       	           list[cnt_list++]=s;
		       else if(xx[i]>=rec[s].lx&&xx[i]<=rec[s].rx&&yy[j]>=rec[s].ly&&yy[j]<=rec[s].ry)
           	       break;
		   }
           if(s<k)
               continue;
           now=0;
           int vx,vy;
		   for(s=0;s<i;s++)
           {
           	   vy=0;
           	   for(p=0;p<j;p++)
           	   {
   	           	   int rs=mc[xx[i]][yy[j]];
       	          if(xx[s]>=0)
   	           	      rs-=mc[xx[s]][yy[j]];
        	       if(yy[p]>=0)
        	          rs-=mc[xx[i]][yy[p]];
     	           if(xx[s]>=0&&yy[p]>=0)
     	              rs+=mc[xx[s]][yy[p]];
  	               if(rs>3)
  	                  continue;
				   int qq,dy,dx;
	               dy=yy[p+1]-yy[p];
                   dx=xx[s+1]-xx[s];
                   rs=0;
				   for(qq=0;qq<cnt_list;qq++)
                   {
                   	   q=list[qq];
               	       if(xx[s]+1<=rec[q].lx&yy[p]+1<=rec[q].ly)
						  rs++;
				   }
                   if(qq>=cnt_list&&rs>=1&&rs<=3&&dx&&dy)
                   {
                   	   for(q=0;q<k;q++)
                   	   {
       	               	   if(rec[q].rx<=xx[i]&&rec[q].lx>=xx[s]+1&&rec[q].ry<=yy[j]&&rec[q].ly>=yy[p]+1)
   	                   	       continue;
                   	       else if(rec[q].rx>=xx[s]+1&&rec[q].lx<=xx[i]&&rec[q].ry>=yy[p]+1&&rec[q].ly<=yy[j])
                   	           break;
   	                   }
   	                   if(q>=k)
   	                   {
   	                   	//  if(i==1&&j==3)
   	                   	  //   printf("s=%d,p=%d,dx=%d,dy=%d,xx=%d,yy=%d\n",s,p,dx,dy,xx[s],yy[p]);
                     	   now+=(long long)dx*(long long)dy;
   	                   }
				   }
   	           }
           }
        //   printf("i=%d,j=%d,now=%I64d,xx=%d,yy=%d\n",i,j,now,xx[i],yy[j]);
           now=(long long)now*(long long)(xx[i+1]-xx[i]);
           now=(long long)now*(long long)(yy[j+1]-yy[j]);
           ans+=now;
       }
       printf("%I64d\n",ans);
	return 0;
}
/*
5 8 1
..******
..******
........
........
........

*/


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
struct segment
{
	int l,r,fu;
	bool operator <(const segment &temp)const
	{
		return l<temp.l;
	}
};
segment sg[5000];
int cnt_sg;
const int inf=1e9;
int xx[400],yy[400];
int cnt_x,cnt_y;
struct rectangle
{
	int lx,ly,rx,ry;
};
rectangle rec[99];
int n,m,k,cnt,mc[1111][1111],nc[1111][11111],list[99],cnt_list,ls[99],cnt_ls;
long long ans,now;
char str[1111][1111];
bool vsx[400],vsy[400];
int main()
{
	int i,j,s,p,q,id,dx1,dx2,dy1,dy2,lx,ly,rx,ry,pn;
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++)
	   scanf("%s",str[i]);
    cnt=0;
	for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   if(str[i][j]=='*'&&!(i>0&&str[i-1][j]=='*')&&!(j>0&&str[i][j-1]=='*'))
       	   {
  	       	   rec[cnt].lx=i;
  	       	   rec[cnt].ly=j;
  	       	   for(s=i;s<n;s++)
  	       	   {
  	       	      for(p=j;p<m;p++)
  	       	      {
     	       	      if(str[s][p]!='*')
						  break;
     	          }
                  if(p==j)
                     break;
                  rec[cnt].ry=p-1;
  	       	   }
      	       rec[cnt++].rx=s-1;
   	       }
       }
    memset(mc,0,sizeof(mc));
    memset(nc,0,sizeof(nc));
    for(i=0;i<k;i++)
       mc[rec[i].lx][rec[i].ly]++;
	for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   mc[i+1][j]+=mc[i][j];
       	   mc[i][j+1]+=mc[i][j];
       	   mc[i+1][j+1]-=mc[i][j];
       }
    cnt_x=cnt_y=0;
    for(i=0;i<k;i++)
    {
    	xx[cnt_x++]=rec[i].lx;
    	xx[cnt_x++]=rec[i].rx;
    	if(rec[i].lx-1>=0)
        	xx[cnt_x++]=rec[i].lx-1;
    	if(rec[i].rx+1<n)
 	 	    xx[cnt_x++]=rec[i].rx+1;
    	yy[cnt_y++]=rec[i].ly;
    	yy[cnt_y++]=rec[i].ry;
		if(rec[i].ly-1>=0)
     		yy[cnt_y++]=rec[i].ly-1;
		if(rec[i].ry+1<m)
		    yy[cnt_y++]=rec[i].ry+1;
    }
    sort(xx,xx+cnt_x);
    sort(yy,yy+cnt_y);
    int nn=0;
    for(i=0;i<cnt_x;i++)
    {
    	if(nn==0||xx[nn-1]<xx[i])
    	   xx[nn++]=xx[i];
    }
    cnt_x=nn;
    nn=0;
    for(i=0;i<cnt_y;i++)
    {
    	if(nn==0||yy[nn-1]<yy[i])
    	    yy[nn++]=yy[i];
    }
    cnt_y=nn;
	ans=0;
    for(i=0;i<cnt_x;i++)
    {
    	if(i==0)
	    	dx1=xx[i]+1;
	    else
	        dx1=xx[i]-xx[i-1];
    	for(j=i+1;j<=cnt_x;j++)
    	{
    		if(j==cnt_x)
    		   dx2=n-xx[j-1];
 		    else
 		       dx2=xx[j]-xx[j-1];
    		cnt_sg=0;
	    	for(s=0;s<k;s++)
	    	{
	    	    if(rec[s].rx<xx[i]||rec[s].lx>xx[j-1])
	    	       continue;
  	            if((rec[s].rx>=xx[i]&&rec[s].lx<xx[i])||(rec[s].rx>xx[j-1]&&rec[s].lx<=xx[j-1]))
  	               sg[cnt_sg].fu=1;
                else
                   sg[cnt_sg].fu=0;
				sg[cnt_sg].l=rec[s].ly;
                sg[cnt_sg++].r=rec[s].ry;
	    	}
	    	sort(sg,sg+cnt_sg);
	    	nn=0;
	    	for(s=0;s<cnt_sg;s++)
	    	{
	    		if(nn==0||sg[nn-1].r<sg[s].l)
	    		   sg[nn++]=sg[s];
  		        else
  		        {
  		           sg[nn-1].r=max(sg[nn-1].r,sg[s].r);
  		           sg[nn-1].fu=max(sg[nn-1].fu,sg[s].fu);
			    }
			}
	    	cnt_sg=nn;
	    	for(s=1;s<=cnt_sg;s++)
	    	{
	    		if(s<cnt_sg)
	        		dy2=sg[s].l-sg[s-1].r;
	    		else
	    		    dy2=m-sg[s-1].r;
        		 pn=0;
				for(p=s-1;p>=0;p--)
	    		{
		    		lx=xx[i];
	                ly=sg[p].l;
	                rx=xx[j-1];
	                ry=sg[s-1].r;
	                int rs=mc[rx][ry];
	                if(lx>0)
	                  rs-=mc[lx-1][ry];
                    if(ly>0)
                      rs-=mc[rx][ly-1];
                    if(lx>0&&ly>0)
                      rs+=mc[lx-1][ly-1];
                    if(rs>3||sg[p].fu==1)
                        break;
                    if(rs==0)
                       continue;
                    if(p==0)
                       dy1=sg[p].l+1;
                    else
                       dy1=sg[p].l-sg[p-1].r;
                     pn+=dy1;
		    	}
		    	ans+=(long long)pn*(long long)dy2*(long long)dx1*(long long)dx2;
	    	}
	    }
    }
	printf("%lld\n",ans);
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
const int inf=1e9;
int xx[400],yy[400];
int cnt_x,cnt_y;
struct rectangle
{
	int lx,ly,rx,ry;
};
rectangle rec[99];
int n,m,k,cnt,mc[1111][1111],list[99],cnt_list;
long long ans,now;
char str[1111][1111];
int main()
{
	int i,j,s,p,q,id;
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++)
	   scanf("%s",str[i]);
    cnt=0;
	for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   if(str[i][j]=='*'&&!(i>0&&str[i-1][j]=='*')&&!(j>0&&str[i][j-1]=='*'))
       	   {
  	       	   rec[cnt].lx=i;
  	       	   rec[cnt].ly=j;
  	       	   for(s=i;s<n;s++)
  	       	   {
  	       	      for(p=j;p<m;p++)
  	       	      {
     	       	      if(str[s][p]!='*')
						  break;
     	          }
                  if(p==j)
                     break;
                  rec[cnt].ry=p-1;
  	       	   }
      	       rec[cnt++].rx=s-1;
   	       }
       }
    memset(mc,0,sizeof(mc));
    for(i=0;i<k;i++)
       mc[rec[i].lx][rec[i].ly]++;
    for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   mc[i+1][j]+=mc[i][j];
       	   mc[i][j+1]+=mc[i][j];
       	   mc[i+1][j+1]-=mc[i][j];
       }
    cnt_x=cnt_y=0;
    xx[cnt_x++]=-1;
    yy[cnt_y++]=-1;
    for(i=0;i<k;i++)
    {
    	xx[cnt_x++]=rec[i].lx;
    	xx[cnt_x++]=rec[i].rx;
    	if(rec[i].lx-1>=0)
        	xx[cnt_x++]=rec[i].lx-1;
    	if(rec[i].rx+1<n)
 	 	    xx[cnt_x++]=rec[i].rx+1;
    	yy[cnt_y++]=rec[i].ly;
    	yy[cnt_y++]=rec[i].ry;
		if(rec[i].ly-1>=0)
     		yy[cnt_y++]=rec[i].ly-1;
		if(rec[i].ry+1<m)
		    yy[cnt_y++]=rec[i].ry+1;
    }
    sort(xx,xx+cnt_x);
    sort(yy,yy+cnt_y);
    int nn=0;
    for(i=0;i<cnt_x;i++)
    {
    	if(nn==0||xx[nn-1]<xx[i])
    	   xx[nn++]=xx[i];
    }
    cnt_x=nn;
    nn=0;
    for(i=0;i<cnt_y;i++)
    {
    	if(nn==0||yy[nn-1]<yy[i])
    	    yy[nn++]=yy[i];
    }
    cnt_y=nn;
    xx[cnt_x++]=n;
    yy[cnt_y++]=m;
	ans=0;
    for(i=1;i<cnt_x-1;i++)
       for(j=1;j<cnt_y-1;j++)
       {
       	   cnt_list=0;
           for(s=0;s<k;s++)
           {
       	       if(rec[s].rx<=xx[i]&&rec[s].ry<=yy[j])
       	           list[cnt_list++]=s;
		       else if(xx[i]>=rec[s].lx&&xx[i]<=rec[s].rx&&yy[j]>=rec[s].ly&&yy[j]<=rec[s].ry)
           	       break;
		   }
           if(s<k)
               continue;
           now=0;
           int vx,vy;
		   for(s=i-1;s>=0;s--)
           {
           	   vy=0;
           	   for(p=j-1;p>=0;p--)
           	   {
   	           	   int rs=mc[xx[i]][yy[j]];
       	          if(xx[s]>=0)
   	           	      rs-=mc[xx[s]][yy[j]];
        	       if(yy[p]>=0)
        	          rs-=mc[xx[i]][yy[p]];
     	           if(xx[s]>=0&&yy[p]>=0)
     	              rs+=mc[xx[s]][yy[p]];
  	               if(rs>3)
  	                  break;
                   if(rs==0)
                       continue;
				   int qq,dy,dx;
	               dy=yy[p+1]-yy[p];
                   dx=xx[s+1]-xx[s];
                   rs=0;
				   for(qq=0;qq<cnt_list;qq++)
                   {
                   	   q=list[qq];
               	       if(xx[s]+1<=rec[q].lx&yy[p]+1<=rec[q].ly)
						  rs++;
				   }
                   if(qq>=cnt_list&&rs>=1&&rs<=3&&dx&&dy)
                   {
                   	   for(q=0;q<k;q++)
                   	   {
       	               	   if(rec[q].rx<=xx[i]&&rec[q].lx>=xx[s]+1&&rec[q].ry<=yy[j]&&rec[q].ly>=yy[p]+1)
   	                   	       continue;
                   	       else if(rec[q].rx>=xx[s]+1&&rec[q].lx<=xx[i]&&rec[q].ry>=yy[p]+1&&rec[q].ly<=yy[j])
                   	           break;
   	                   }
   	                   if(q>=k)
                     	   now+=(long long)dx*(long long)dy;
				   }
   	           }
           }
           now=(long long)now*(long long)(xx[i+1]-xx[i]);
           now=(long long)now*(long long)(yy[j+1]-yy[j]);
           ans+=now;
       }
       printf("%I64d\n",ans);
	return 0;
}
/*
5 8 1
..******
..******
........
........
........

*/


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
const int inf=1e9;
int xx[400],yy[400];
int cnt_x,cnt_y;
struct rectangle
{
	int lx,ly,rx,ry;
};
rectangle rec[99];
int n,m,k,cnt,mc[111][111],list[99],cnt_list,can_x[200],can_y[200],cx,cy;
bool no[111][111];
long long ans,now;
char str[111][111];
int main()
{
	int i,j,s,p,q,id;
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++)
	   scanf("%s",str[i]);
    cnt=0;
	for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   if(str[i][j]=='*'&&!(i>0&&str[i-1][j]=='*')&&!(j>0&&str[i][j-1]=='*'))
       	   {
  	       	   rec[cnt].lx=i;
  	       	   rec[cnt].ly=j;
  	       	   for(s=i;s<n;s++)
  	       	   {
  	       	      for(p=j;p<m;p++)
  	       	      {
     	       	      if(str[s][p]!='*')
						  break;
     	          }
                  if(p==j)
                     break;
                  rec[cnt].ry=p-1;
  	       	   }
      	       rec[cnt++].rx=s-1;
      	     //  printf("lx=%d,ly=%d,rx=%d,ry=%d\n",rec[cnt-1].lx,rec[cnt-1].ly,rec[cnt-1].rx,rec[cnt-1].ry);
   	       }
       }
    memset(mc,0,sizeof(mc));
    for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   for(s=0;s<k;s++)
		   {
	           if(rec[s].lx<=i&&rec[s].ly<=j)
	                mc[i][j]++;
  		   }
       }
    cnt_x=cnt_y=0;
    for(i=0;i<k;i++)
    {
    	xx[cnt_x++]=rec[i].lx;
    	xx[cnt_x++]=rec[i].rx;
    	if(rec[i].lx-1>=0)
        	xx[cnt_x++]=rec[i].lx-1;
    	if(rec[i].rx+1<n)
 	 	    xx[cnt_x++]=rec[i].rx+1;
    	yy[cnt_y++]=rec[i].ly;
    	yy[cnt_y++]=rec[i].ry;
		if(rec[i].ly-1>=0)
     		yy[cnt_y++]=rec[i].ly-1;
		if(rec[i].ry+1<m)
		    yy[cnt_y++]=rec[i].ry+1;
    }
    sort(xx,xx+cnt_x);
    sort(yy,yy+cnt_y);
    int nn=0;
    for(i=0;i<cnt_x;i++)
    {
    	if(nn==0||xx[nn-1]<xx[i])
    	   xx[nn++]=xx[i];
    }
    cnt_x=nn;
    nn=0;
    for(i=0;i<cnt_y;i++)
    {
    	if(nn==0||yy[nn-1]<yy[i])
    	    yy[nn++]=yy[i];
    }
    cnt_y=nn;
    xx[cnt_x++]=n;
    yy[cnt_y++]=m;
	ans=0;
    for(i=0;i<cnt_x-1;i++)
       for(j=0;j<cnt_y-1;j++)
       {
       	   cnt_list=0;
           for(s=0;s<k;s++)
           {
       	       if(rec[s].rx<=xx[i]&&rec[s].ry<=yy[j])
       	           list[cnt_list++]=s;
		       else if(xx[i]>=rec[s].lx&&xx[i]<=rec[s].rx&&yy[j]>=rec[s].ly&&yy[j]<=rec[s].ry)
           	       break;
		   }
           if(s<k)
               continue;
           now=0;
           int vx,vy;
		   for(s=0;s<=i;s++)
           {
           	   vy=0;
           	   for(p=0;p<=j;p++)
           	   {
   	           	   int rs=mc[xx[i]][yy[j]];
   	           	   if(xx[s])
   	           	      rs-=mc[xx[s]-1][yy[j]];
        	       if(yy[p])
        	          rs-=mc[xx[i]][yy[p]-1];
     	           if(xx[s]&&yy[p])
     	              rs+=mc[xx[s]-1][yy[p]-1];
  	               if(rs>3)
  	                  continue;
				   int qq,dy,dx;
				   if(p==j)
				      dy=1;
	               else
	                  dy=yy[p+1]-yy[p];
                   rs=0;
				   for(qq=0;qq<cnt_list;qq++)
                   {
                   	   q=list[qq];
               	       if(xx[s]<=rec[q].lx&yy[p]<=rec[q].ly)
               	       {
               	           rs++;
               	           if(xx[s]==rec[q].rx)
               	               dx=1;
           	               if(yy[p]==rec[q].ry)
           	                   dy=1;
               	       }
               	        else if(xx[s]<=rec[q].rx&&xx[s]>=rec[q].lx&&yy[p]<=rec[q].ry&&yy[p]>=rec[q].ly)
           	                break;
				   }
                   if(qq>=cnt_list&&rs>=1&&rs<=3&&dx&&dy)
                   {
                   	   for(q=0;q<k;q++)
                   	   {
   	                   	   if(rec[q].rx<=xx[i]&&rec[q].lx>=xx[s]&&rec[q].ry<=yy[j]&&rec[q].ly>=yy[p])
   	                   	       continue;
                   	       if(rec[q].rx>=xx[s]&&rec[q].lx<=xx[i]&&rec[q].ry>=yy[p]&&rec[q].ly<=yy[j])
                   	           break;
   	                   }
   	                   if(q>=k)
                     	   now+=(long long)dx*(long long)dy;
                   }
   	           }
           }
           now=(long long)now*(long long)(xx[i+1]-xx[i]);
           now=(long long)now*(long long)(yy[j+1]-yy[j]);
           ans+=now;
       }
       printf("%I64d\n",ans);
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
const int inf=1e9;
int xx[400],yy[400];
int cnt_x,cnt_y;
struct rectangle
{
	int lx,ly,rx,ry;
};
rectangle rec[99];
int n,m,k,cnt,mc[111][111],list[99],cnt_list,can_x[200],can_y[200],cx,cy;
bool no[111][111];
long long ans,now;
char str[111][111];
int main()
{
	int i,j,s,p,q,id;
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++)
	   scanf("%s",str[i]);
    cnt=0;
	for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   if(str[i][j]=='*'&&!(i>0&&str[i-1][j]=='*')&&!(j>0&&str[i][j-1]=='*'))
       	   {
  	       	   rec[cnt].lx=i;
  	       	   rec[cnt].ly=j;
  	       	   for(s=i;s<n;s++)
  	       	   {
  	       	      for(p=j;p<m;p++)
  	       	      {
     	       	      if(str[s][p]!='*')
						  break;
     	          }
                  if(p==j)
                     break;
                  rec[cnt].ry=p-1;
  	       	   }
      	       rec[cnt++].rx=s-1;
   	       }
       }
    memset(mc,0,sizeof(mc));
    for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   for(s=0;s<k;s++)
		   {
	           if(rec[s].lx<=i&&rec[s].ly<=j)
	                mc[i][j]++;
  		   }
       }
    cnt_x=cnt_y=0;
    xx[cnt_x++]=-1;
    yy[cnt_y++]=-1;
    for(i=0;i<k;i++)
    {
    	xx[cnt_x++]=rec[i].lx;
    	xx[cnt_x++]=rec[i].rx;
    	if(rec[i].lx-1>=0)
        	xx[cnt_x++]=rec[i].lx-1;
    	if(rec[i].rx+1<n)
 	 	    xx[cnt_x++]=rec[i].rx+1;
    	yy[cnt_y++]=rec[i].ly;
    	yy[cnt_y++]=rec[i].ry;
		if(rec[i].ly-1>=0)
     		yy[cnt_y++]=rec[i].ly-1;
		if(rec[i].ry+1<m)
		    yy[cnt_y++]=rec[i].ry+1;
    }
    sort(xx,xx+cnt_x);
    sort(yy,yy+cnt_y);
    int nn=0;
    for(i=0;i<cnt_x;i++)
    {
    	if(nn==0||xx[nn-1]<xx[i])
    	   xx[nn++]=xx[i];
    }
    cnt_x=nn;
    nn=0;
    for(i=0;i<cnt_y;i++)
    {
    	if(nn==0||yy[nn-1]<yy[i])
    	    yy[nn++]=yy[i];
    }
    cnt_y=nn;
    xx[cnt_x++]=n;
    yy[cnt_y++]=m;
	ans=0;
    for(i=1;i<cnt_x-1;i++)
       for(j=1;j<cnt_y-1;j++)
       {
       	   cnt_list=0;
           for(s=0;s<k;s++)
           {
       	       if(rec[s].rx<=xx[i]&&rec[s].ry<=yy[j])
       	           list[cnt_list++]=s;
		       else if(xx[i]>=rec[s].lx&&xx[i]<=rec[s].rx&&yy[j]>=rec[s].ly&&yy[j]<=rec[s].ry)
           	       break;
		   }
           if(s<k)
               continue;
           now=0;
           int vx,vy;
		   for(s=0;s<i;s++)
           {
           	   vy=0;
           	   for(p=0;p<j;p++)
           	   {
   	           	   int rs=mc[xx[i]][yy[j]];
   	           	   if(xx[s]>0)
   	           	      rs-=mc[xx[s]-1][yy[j]];
        	       if(yy[p]>0)
        	          rs-=mc[xx[i]][yy[p]-1];
     	           if(xx[s]>0&&yy[p]>0)
     	              rs+=mc[xx[s]-1][yy[p]-1];
  	               if(rs>3)
  	                  continue;
				   int qq,dy,dx;
	               dy=yy[p+1]-yy[p];
                   dx=xx[s+1]-xx[s];
                   rs=0;
				   for(qq=0;qq<cnt_list;qq++)
                   {
                   	   q=list[qq];
               	       if(xx[s]<=rec[q].lx&yy[p]<=rec[q].ly)
               	       {
               	       	  if(xx[s]==rec[q].lx||yy[p]==rec[q].ly)
               	       	      break;
						  rs++;
               	       }
				   }
                   if(qq>=cnt_list&&rs>=1&&rs<=3&&dx&&dy)
                   {
                   	   for(q=0;q<k;q++)
                   	   {
       	               	   if(rec[q].rx<=xx[i]&&rec[q].lx>=xx[s]&&rec[q].ry<=yy[j]&&rec[q].ly>=yy[p])
   	                   	       continue;
                   	       else if(rec[q].rx>=xx[s]+1&&rec[q].lx<=xx[i]&&rec[q].ry>=yy[p]+1&&rec[q].ly<=yy[j])
                   	           break;
   	                   }
   	                   if(q>=k)
   	                   {
   	                   	//  if(i==4&&j==4)
   	                   	 //    printf("s=%d,p=%d,dx=%d,dy=%d,xx=%d,yy=%d\n",s,p,dx,dy,xx[s],yy[p]);
                     	   now+=(long long)dx*(long long)dy;
   	                   }
				   }
   	           }
           }
           //printf("i=%d,j=%d,now=%I64d,xx=%d,yy=%d\n",i,j,now,xx[i],yy[j]);
           now=(long long)now*(long long)(xx[i+1]-xx[i]);
           now=(long long)now*(long long)(yy[j+1]-yy[j]);
           ans+=now;
       }
       printf("%I64d\n",ans);
	return 0;
}
/*
5 8 1
..******
..******
........
........
........

*/


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
const int inf=1e9;
int xx[400],yy[400];
int cnt_x,cnt_y;
struct rectangle
{
	int lx,ly,rx,ry;
};
rectangle rec[99];
int n,m,k,cnt,mc[1111][1111],list[99],cnt_list;
long long ans,now;
char str[1111][1111];
int main()
{
	int i,j,s,p,q,id;
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++)
	   scanf("%s",str[i]);
    cnt=0;
	for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   if(str[i][j]=='*'&&!(i>0&&str[i-1][j]=='*')&&!(j>0&&str[i][j-1]=='*'))
       	   {
  	       	   rec[cnt].lx=i;
  	       	   rec[cnt].ly=j;
  	       	   for(s=i;s<n;s++)
  	       	   {
  	       	      for(p=j;p<m;p++)
  	       	      {
     	       	      if(str[s][p]!='*')
						  break;
     	          }
                  if(p==j)
                     break;
                  rec[cnt].ry=p-1;
  	       	   }
      	       rec[cnt++].rx=s-1;
   	       }
       }
    memset(mc,0,sizeof(mc));
    for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   for(s=0;s<k;s++)
		   {
	           if(rec[s].lx<=i&&rec[s].ly<=j)
	                mc[i][j]++;
  		   }
       }
    cnt_x=cnt_y=0;
    xx[cnt_x++]=-1;
    yy[cnt_y++]=-1;
    for(i=0;i<k;i++)
    {
    	xx[cnt_x++]=rec[i].lx;
    	xx[cnt_x++]=rec[i].rx;
    	if(rec[i].lx-1>=0)
        	xx[cnt_x++]=rec[i].lx-1;
    	if(rec[i].rx+1<n)
 	 	    xx[cnt_x++]=rec[i].rx+1;
    	yy[cnt_y++]=rec[i].ly;
    	yy[cnt_y++]=rec[i].ry;
		if(rec[i].ly-1>=0)
     		yy[cnt_y++]=rec[i].ly-1;
		if(rec[i].ry+1<m)
		    yy[cnt_y++]=rec[i].ry+1;
    }
    sort(xx,xx+cnt_x);
    sort(yy,yy+cnt_y);
    int nn=0;
    for(i=0;i<cnt_x;i++)
    {
    	if(nn==0||xx[nn-1]<xx[i])
    	   xx[nn++]=xx[i];
    }
    cnt_x=nn;
    nn=0;
    for(i=0;i<cnt_y;i++)
    {
    	if(nn==0||yy[nn-1]<yy[i])
    	    yy[nn++]=yy[i];
    }
    cnt_y=nn;
    xx[cnt_x++]=n;
    yy[cnt_y++]=m;
	ans=0;
    for(i=1;i<cnt_x-1;i++)
       for(j=1;j<cnt_y-1;j++)
       {
       	   cnt_list=0;
           for(s=0;s<k;s++)
           {
       	       if(rec[s].rx<=xx[i]&&rec[s].ry<=yy[j])
       	           list[cnt_list++]=s;
		       else if(xx[i]>=rec[s].lx&&xx[i]<=rec[s].rx&&yy[j]>=rec[s].ly&&yy[j]<=rec[s].ry)
           	       break;
		   }
           if(s<k)
               continue;
           now=0;
           int vx,vy;
		   for(s=0;s<i;s++)
           {
           	   vy=0;
           	   for(p=0;p<j;p++)
           	   {
   	           	   int rs=mc[xx[i]][yy[j]];
       	          if(xx[s]>=0)
   	           	      rs-=mc[xx[s]][yy[j]];
        	       if(yy[p]>=0)
        	          rs-=mc[xx[i]][yy[p]];
     	           if(xx[s]>=0&&yy[p]>=0)
     	              rs+=mc[xx[s]][yy[p]];
  	               if(rs>3)
  	                  continue;
				   int qq,dy,dx;
	               dy=yy[p+1]-yy[p];
                   dx=xx[s+1]-xx[s];
                   rs=0;
				   for(qq=0;qq<cnt_list;qq++)
                   {
                   	   q=list[qq];
               	       if(xx[s]+1<=rec[q].lx&yy[p]+1<=rec[q].ly)
						  rs++;
				   }
                   if(qq>=cnt_list&&rs>=1&&rs<=3&&dx&&dy)
                   {
                   	   for(q=0;q<k;q++)
                   	   {
       	               	   if(rec[q].rx<=xx[i]&&rec[q].lx>=xx[s]+1&&rec[q].ry<=yy[j]&&rec[q].ly>=yy[p]+1)
   	                   	       continue;
                   	       else if(rec[q].rx>=xx[s]+1&&rec[q].lx<=xx[i]&&rec[q].ry>=yy[p]+1&&rec[q].ly<=yy[j])
                   	           break;
   	                   }
   	                   if(q>=k)
   	                   {
   	                   	//  if(i==1&&j==3)
   	                   	  //   printf("s=%d,p=%d,dx=%d,dy=%d,xx=%d,yy=%d\n",s,p,dx,dy,xx[s],yy[p]);
                     	   now+=(long long)dx*(long long)dy;
   	                   }
				   }
   	           }
           }
        //   printf("i=%d,j=%d,now=%I64d,xx=%d,yy=%d\n",i,j,now,xx[i],yy[j]);
           now=(long long)now*(long long)(xx[i+1]-xx[i]);
           now=(long long)now*(long long)(yy[j+1]-yy[j]);
           ans+=now;
       }
       printf("%I64d\n",ans);
	return 0;
}
/*
5 8 1
..******
..******
........
........
........

*/


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
const int inf=1e9;
int xx[400],yy[400];
int cnt_x,cnt_y;
struct rectangle
{
	int lx,ly,rx,ry;
};
rectangle rec[99];
int n,m,k,cnt,mc[1111][1111],list[99],cnt_list;
long long ans,now;
char str[1111][1111];
bool vsx[400],vsy[400];
int main()
{
	int i,j,s,p,q,id;
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++)
	   scanf("%s",str[i]);
    cnt=0;
	for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   if(str[i][j]=='*'&&!(i>0&&str[i-1][j]=='*')&&!(j>0&&str[i][j-1]=='*'))
       	   {
  	       	   rec[cnt].lx=i;
  	       	   rec[cnt].ly=j;
  	       	   for(s=i;s<n;s++)
  	       	   {
  	       	      for(p=j;p<m;p++)
  	       	      {
     	       	      if(str[s][p]!='*')
						  break;
     	          }
                  if(p==j)
                     break;
                  rec[cnt].ry=p-1;
  	       	   }
      	       rec[cnt++].rx=s-1;
   	       }
       }
    memset(mc,0,sizeof(mc));
    for(i=0;i<k;i++)
       mc[rec[i].lx][rec[i].ly]++;
    for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   mc[i+1][j]+=mc[i][j];
       	   mc[i][j+1]+=mc[i][j];
       	   mc[i+1][j+1]-=mc[i][j];
       }
    cnt_x=cnt_y=0;
    xx[cnt_x++]=-1;
    yy[cnt_y++]=-1;
    for(i=0;i<k;i++)
    {
    	xx[cnt_x++]=rec[i].lx;
    	xx[cnt_x++]=rec[i].rx;
    	if(rec[i].lx-1>=0)
        	xx[cnt_x++]=rec[i].lx-1;
    	if(rec[i].rx+1<n)
 	 	    xx[cnt_x++]=rec[i].rx+1;
    	yy[cnt_y++]=rec[i].ly;
    	yy[cnt_y++]=rec[i].ry;
		if(rec[i].ly-1>=0)
     		yy[cnt_y++]=rec[i].ly-1;
		if(rec[i].ry+1<m)
		    yy[cnt_y++]=rec[i].ry+1;
    }
    sort(xx,xx+cnt_x);
    sort(yy,yy+cnt_y);
    int nn=0;
    for(i=0;i<cnt_x;i++)
    {
    	if(nn==0||xx[nn-1]<xx[i])
    	   xx[nn++]=xx[i];
    }
    cnt_x=nn;
    nn=0;
    for(i=0;i<cnt_y;i++)
    {
    	if(nn==0||yy[nn-1]<yy[i])
    	    yy[nn++]=yy[i];
    }
    cnt_y=nn;
    xx[cnt_x++]=n;
    yy[cnt_y++]=m;
	ans=0;
    for(i=1;i<cnt_x-1;i++)
       for(j=1;j<cnt_y-1;j++)
       {
       	   cnt_list=0;
		   for(s=0;s<k;s++)
           {
       	       if(rec[s].rx<=xx[i]&&rec[s].ry<=yy[j])
       	           list[cnt_list++]=s;
		       else if(xx[i]>=rec[s].lx&&xx[i]<=rec[s].rx&&yy[j]>=rec[s].ly&&yy[j]<=rec[s].ry)
           	       break;
		   }
           if(s<k)
               continue;
           now=0;
           int vx,vy;
           memset(vsx,false,sizeof(vsx));
           for(s=0;s<=i;s++)
           {
           	   for(q=0;q<k;q++)
           	   {
           	   	   if(xx[i]>=rec[q].rx&&xx[s]<=rec[q].lx&&rec[q].ry<=yy[j])
           	   	       continue;
   	           	   if(rec[q].rx>=xx[s]+1&&rec[q].lx<=xx[i]&&rec[q].ly<=yy[j]&&rec[q].ry>=yy[j])
  	           	      break;
   	           }
   	           if(q<k)
                    vsx[s]=true;
           }
           for(s=0;s<=j;s++)
           {
           	   for(q=0;q<k;q++)
           	   {
   	           	   if(yy[j]>=rec[q].ry&&yy[s]<=rec[q].ly&&rec[q].rx<=xx[i])
   	           	      continue;
        	       if(rec[q].ry>=yy[s]+1&&rec[q].ly<=yy[j]&&rec[q].lx<=xx[i]&&rec[q].rx>=xx[i])
        	          break;
   	           }
   	           if(q<k)
   	               vsy[s]=true;
           }
		   for(s=i-1;s>=0;s--)
           {
           	   vy=0;
			   if(vsx[s])
			      continue;
			   for(p=j-1;p>=0;p--)
           	   {
           	   	  if(vsy[p])
           	   	      continue;
   	           	   int rs=mc[xx[i]][yy[j]];
       	          if(xx[s]>=0)
   	           	      rs-=mc[xx[s]][yy[j]];
        	       if(yy[p]>=0)
        	          rs-=mc[xx[i]][yy[p]];
     	           if(xx[s]>=0&&yy[p]>=0)
     	              rs+=mc[xx[s]][yy[p]];
  	               if(rs>3)
  	                  break;
                   if(rs==0)
                       continue;
				   int qq,dy,dx;
	               dy=yy[p+1]-yy[p];
                   if(dx&&dy)
                   {
                   	   for(q=0;q<k;q++)
                   	   {
       	               	   if(rec[q].rx<=xx[i]&&rec[q].lx>=xx[s]+1&&rec[q].ry<=yy[j]&&rec[q].ly>=yy[p]+1)
   	                   	       continue;
                   	       else if(rec[q].rx>=xx[s]+1&&rec[q].lx<=xx[i]&&rec[q].ry>=yy[p]+1&&rec[q].ly<=yy[j])
                   	           break;
   	                   }
   	                   if(q>=k)
                     	   vy+=dy;
				   }
   	           }
   	           now+=(long long)vy*(long long)(xx[s+1]-xx[s]);
           }
           now=(long long)now*(long long)(xx[i+1]-xx[i]);
           now=(long long)now*(long long)(yy[j+1]-yy[j]);
           ans+=now;
       }
       printf("%I64d\n",ans);
	return 0;
}
/*
5 8 1
..******
..******
........
........
........

*/


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
const int inf=1e9;
int xx[400],yy[400];
int cnt_x,cnt_y;
struct rectangle
{
	int lx,ly,rx,ry;
};
rectangle rec[99];
int n,m,k,cnt,mc[1111][1111],list[99],cnt_list;
long long ans,now;
char str[1111][1111];
int main()
{
	int i,j,s,p,q,id;
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++)
	   scanf("%s",str[i]);
    cnt=0;
	for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   if(str[i][j]=='*'&&!(i>0&&str[i-1][j]=='*')&&!(j>0&&str[i][j-1]=='*'))
       	   {
  	       	   rec[cnt].lx=i;
  	       	   rec[cnt].ly=j;
  	       	   for(s=i;s<n;s++)
  	       	   {
  	       	      for(p=j;p<m;p++)
  	       	      {
     	       	      if(str[s][p]!='*')
						  break;
     	          }
                  if(p==j)
                     break;
                  rec[cnt].ry=p-1;
  	       	   }
      	       rec[cnt++].rx=s-1;
   	       }
       }
    memset(mc,0,sizeof(mc));
    for(i=0;i<k;i++)
       mc[rec[i].lx][rec[i].ly]++;
    for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   mc[i+1][j]+=mc[i][j];
       	   mc[i][j+1]+=mc[i][j];
       	   mc[i+1][j+1]-=mc[i][j];
       }
    cnt_x=cnt_y=0;
    xx[cnt_x++]=-1;
    yy[cnt_y++]=-1;
    for(i=0;i<k;i++)
    {
    	xx[cnt_x++]=rec[i].lx;
    	xx[cnt_x++]=rec[i].rx;
    	if(rec[i].lx-1>=0)
        	xx[cnt_x++]=rec[i].lx-1;
    	if(rec[i].rx+1<n)
 	 	    xx[cnt_x++]=rec[i].rx+1;
    	yy[cnt_y++]=rec[i].ly;
    	yy[cnt_y++]=rec[i].ry;
		if(rec[i].ly-1>=0)
     		yy[cnt_y++]=rec[i].ly-1;
		if(rec[i].ry+1<m)
		    yy[cnt_y++]=rec[i].ry+1;
    }
    sort(xx,xx+cnt_x);
    sort(yy,yy+cnt_y);
    int nn=0;
    for(i=0;i<cnt_x;i++)
    {
    	if(nn==0||xx[nn-1]<xx[i])
    	   xx[nn++]=xx[i];
    }
    cnt_x=nn;
    nn=0;
    for(i=0;i<cnt_y;i++)
    {
    	if(nn==0||yy[nn-1]<yy[i])
    	    yy[nn++]=yy[i];
    }
    cnt_y=nn;
    xx[cnt_x++]=n;
    yy[cnt_y++]=m;
	ans=0;
    for(i=1;i<cnt_x-1;i++)
       for(j=1;j<cnt_y-1;j++)
       {
       	   cnt_list=0;
           for(s=0;s<k;s++)
           {
       	       if(rec[s].rx<=xx[i]&&rec[s].ry<=yy[j])
       	           list[cnt_list++]=s;
		       else if(xx[i]>=rec[s].lx&&xx[i]<=rec[s].rx&&yy[j]>=rec[s].ly&&yy[j]<=rec[s].ry)
           	       break;
		   }
           if(s<k)
               continue;
           now=0;
           int vx,vy;
		   for(s=i-1;s>=0;s--)
           {
           	   vy=0;
           	   for(q=0;q<k;q++)
           	   {
           	   	   if(xx[i]>=rec[q].rx&&xx[s]<=rec[q].lx&&rec[q].ry<=yy[j])
           	   	       continue;
   	           	   if(rec[q].rx>=xx[s]+1&&rec[q].lx<=xx[i]&&rec[q].ly<=yy[j]&&rec[q].ry>=yy[j])
  	           	      break;
   	           }
   	           if(q<k)
                    continue;
			   for(p=j-1;p>=0;p--)
           	   {
   	           	   int rs=mc[xx[i]][yy[j]];
       	          if(xx[s]>=0)
   	           	      rs-=mc[xx[s]][yy[j]];
        	       if(yy[p]>=0)
        	          rs-=mc[xx[i]][yy[p]];
     	           if(xx[s]>=0&&yy[p]>=0)
     	              rs+=mc[xx[s]][yy[p]];
  	               if(rs>3)
  	                  break;
                   if(rs==0)
                       continue;
				   int qq,dy,dx;
	               dy=yy[p+1]-yy[p];
                   if(dx&&dy)
                   {
                   	   for(q=0;q<k;q++)
                   	   {
       	               	   if(rec[q].rx<=xx[i]&&rec[q].lx>=xx[s]+1&&rec[q].ry<=yy[j]&&rec[q].ly>=yy[p]+1)
   	                   	       continue;
                   	       else if(rec[q].rx>=xx[s]+1&&rec[q].lx<=xx[i]&&rec[q].ry>=yy[p]+1&&rec[q].ly<=yy[j])
                   	           break;
      	                 //  if(rec[q].rx>=xx[s]+1&&rec[q].lx<=xx[i]&&rec[q].ly<=yy[j]&&rec[q].ry>=yy[j])
      	                      //puts("??");
   	                   }
   	                   if(q>=k)
                     	   vy+=dy;
				   }
   	           }
   	           now+=(long long)vy*(long long)(xx[s+1]-xx[s]);
           }
           now=(long long)now*(long long)(xx[i+1]-xx[i]);
           now=(long long)now*(long long)(yy[j+1]-yy[j]);
           ans+=now;
       }
       printf("%I64d\n",ans);
	return 0;
}
/*
5 8 1
..******
..******
........
........
........

*/


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
struct segment
{
	int l,r,fu;
	bool operator <(const segment &temp)const
	{
		return l<temp.l;
	}
};
segment sg[5000];
int cnt_sg;
const int inf=1e9;
int xx[400],yy[400];
int cnt_x,cnt_y;
struct rectangle
{
	int lx,ly,rx,ry;
};
rectangle rec[99];
int n,m,k,cnt,mc[1111][1111],nc[1111][11111],list[99],cnt_list,ls[99],cnt_ls;
long long ans,now;
char str[1111][1111];
bool vsx[400],vsy[400];
int main()
{
	int i,j,s,p,q,id,dx1,dx2,dy1,dy2,lx,ly,rx,ry,pn;
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++)
	   scanf("%s",str[i]);
    cnt=0;
	for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   if(str[i][j]=='*'&&!(i>0&&str[i-1][j]=='*')&&!(j>0&&str[i][j-1]=='*'))
       	   {
  	       	   rec[cnt].lx=i;
  	       	   rec[cnt].ly=j;
  	       	   for(s=i;s<n;s++)
  	       	   {
  	       	      for(p=j;p<m;p++)
  	       	      {
     	       	      if(str[s][p]!='*')
						  break;
     	          }
                  if(p==j)
                     break;
                  rec[cnt].ry=p-1;
  	       	   }
      	       rec[cnt++].rx=s-1;
   	       }
       }
    memset(mc,0,sizeof(mc));
    memset(nc,0,sizeof(nc));
    for(i=0;i<k;i++)
       mc[rec[i].lx][rec[i].ly]++;
	for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   mc[i+1][j]+=mc[i][j];
       	   mc[i][j+1]+=mc[i][j];
       	   mc[i+1][j+1]-=mc[i][j];
       }
    cnt_x=cnt_y=0;
    for(i=0;i<k;i++)
    {
    	xx[cnt_x++]=rec[i].lx;
    	xx[cnt_x++]=rec[i].rx;
    	if(rec[i].lx-1>=0)
        	xx[cnt_x++]=rec[i].lx-1;
    	if(rec[i].rx+1<n)
 	 	    xx[cnt_x++]=rec[i].rx+1;
    	yy[cnt_y++]=rec[i].ly;
    	yy[cnt_y++]=rec[i].ry;
		if(rec[i].ly-1>=0)
     		yy[cnt_y++]=rec[i].ly-1;
		if(rec[i].ry+1<m)
		    yy[cnt_y++]=rec[i].ry+1;
    }
    sort(xx,xx+cnt_x);
    sort(yy,yy+cnt_y);
    int nn=0;
    for(i=0;i<cnt_x;i++)
    {
    	if(nn==0||xx[nn-1]<xx[i])
    	   xx[nn++]=xx[i];
    }
    cnt_x=nn;
    nn=0;
    for(i=0;i<cnt_y;i++)
    {
    	if(nn==0||yy[nn-1]<yy[i])
    	    yy[nn++]=yy[i];
    }
    cnt_y=nn;
	ans=0;
    for(i=0;i<cnt_x;i++)
    {
    	if(i==0)
	    	dx1=xx[i]+1;
	    else
	        dx1=xx[i]-xx[i-1];
    	for(j=i+1;j<=cnt_x;j++)
    	{
    		if(j==cnt_x)
    		   dx2=n-xx[j-1];
 		    else
 		       dx2=xx[j]-xx[j-1];
    		cnt_sg=0;
	    	for(s=0;s<k;s++)
	    	{
	    	    if(rec[s].rx<xx[i]||rec[s].lx>xx[j-1])
	    	       continue;
  	            if((rec[s].rx>=xx[i]&&rec[s].lx<xx[i])||(rec[s].rx>xx[j-1]&&rec[s].lx<=xx[j-1]))
  	               sg[cnt_sg].fu=1;
                else
                   sg[cnt_sg].fu=0;
				sg[cnt_sg].l=rec[s].ly;
                sg[cnt_sg++].r=rec[s].ry;
	    	}
	    	sort(sg,sg+cnt_sg);
	    	nn=0;
	    	for(s=0;s<cnt_sg;s++)
	    	{
	    		if(nn==0||sg[nn-1].r<sg[s].l)
	    		   sg[nn++]=sg[s];
  		        else
  		        {
  		           sg[nn-1].r=max(sg[nn-1].r,sg[s].r);
  		           sg[nn-1].fu=max(sg[nn-1].fu,sg[s].fu);
			    }
			}
	    	cnt_sg=nn;
	    	for(s=1;s<=cnt_sg;s++)
	    	{
	    		if(s<cnt_sg)
	        		dy2=sg[s].l-sg[s-1].r;
	    		else
	    		    dy2=m-sg[s-1].r;
        		 pn=0;
				for(p=s-1;p>=0;p--)
	    		{
		    		lx=xx[i];
	                ly=sg[p].l;
	                rx=xx[j-1];
	                ry=sg[s-1].r;
	                int rs=mc[rx][ry];
	                if(lx>0)
	                  rs-=mc[lx-1][ry];
                    if(ly>0)
                      rs-=mc[rx][ly-1];
                    if(lx>0&&ly>0)
                      rs+=mc[lx-1][ly-1];
                    if(rs>3||sg[p].fu==1)
                        break;
                    if(rs==0)
                       continue;
                    if(p==0)
                       dy1=sg[p].l+1;
                    else
                       dy1=sg[p].l-sg[p-1].r;
                     pn+=dy1;
		    	}
		    	ans+=(long long)pn*(long long)dy2*(long long)dx1*(long long)dx2;
	    	}
	    }
    }
	printf("%I64d\n",ans);
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
const int inf=1e9;
int xx[400],yy[400];
int cnt_x,cnt_y;
struct rectangle
{
	int lx,ly,rx,ry;
};
rectangle rec[99];
int n,m,k,cnt,mc[111][111],list[99],cnt_list,can_x[200],can_y[200],cx,cy;
bool no[111][111];
long long ans,now;
char str[111][111];
int main()
{
	int i,j,s,p,q,id;
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++)
	   scanf("%s",str[i]);
    cnt=0;
	for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   if(str[i][j]=='*'&&!(i>0&&str[i-1][j]=='*')&&!(j>0&&str[i][j-1]=='*'))
       	   {
  	       	   rec[cnt].lx=i;
  	       	   rec[cnt].ly=j;
  	       	   for(s=i;s<n;s++)
  	       	   {
  	       	      for(p=j;p<m;p++)
  	       	      {
     	       	      if(str[s][p]!='*')
						  break;
     	          }
                  if(p==j)
                     break;
                  rec[cnt].ry=p-1;
  	       	   }
      	       rec[cnt++].rx=s-1;
   	       }
       }
    memset(mc,0,sizeof(mc));
    for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   for(s=0;s<k;s++)
		   {
	           if(rec[s].lx<=i&&rec[s].ly<=j)
	                mc[i][j]++;
  		   }
       }
    cnt_x=cnt_y=0;
    xx[cnt_x++]=-1;
    yy[cnt_y++]=-1;
    for(i=0;i<k;i++)
    {
    	xx[cnt_x++]=rec[i].lx;
    	xx[cnt_x++]=rec[i].rx;
    	if(rec[i].lx-1>=0)
        	xx[cnt_x++]=rec[i].lx-1;
    	if(rec[i].rx+1<n)
 	 	    xx[cnt_x++]=rec[i].rx+1;
    	yy[cnt_y++]=rec[i].ly;
    	yy[cnt_y++]=rec[i].ry;
		if(rec[i].ly-1>=0)
     		yy[cnt_y++]=rec[i].ly-1;
		if(rec[i].ry+1<m)
		    yy[cnt_y++]=rec[i].ry+1;
    }
    sort(xx,xx+cnt_x);
    sort(yy,yy+cnt_y);
    int nn=0;
    for(i=0;i<cnt_x;i++)
    {
    	if(nn==0||xx[nn-1]<xx[i])
    	   xx[nn++]=xx[i];
    }
    cnt_x=nn;
    nn=0;
    for(i=0;i<cnt_y;i++)
    {
    	if(nn==0||yy[nn-1]<yy[i])
    	    yy[nn++]=yy[i];
    }
    cnt_y=nn;
    xx[cnt_x++]=n;
    yy[cnt_y++]=m;
	ans=0;
    for(i=1;i<cnt_x-1;i++)
       for(j=1;j<cnt_y-1;j++)
       {
       	   cnt_list=0;
           for(s=0;s<k;s++)
           {
       	       if(rec[s].rx<=xx[i]&&rec[s].ry<=yy[j])
       	           list[cnt_list++]=s;
		       else if(xx[i]>=rec[s].lx&&xx[i]<=rec[s].rx&&yy[j]>=rec[s].ly&&yy[j]<=rec[s].ry)
           	       break;
		   }
           if(s<k)
               continue;
           now=0;
           int vx,vy;
		   for(s=0;s<i;s++)
           {
           	   vy=0;
           	   for(p=0;p<j;p++)
           	   {
   	           	   int rs=mc[xx[i]][yy[j]];
       	          if(xx[s]>=0)
   	           	      rs-=mc[xx[s]][yy[j]];
        	       if(yy[p]>=0)
        	          rs-=mc[xx[i]][yy[p]];
     	           if(xx[s]>=0&&yy[p]>=0)
     	              rs+=mc[xx[s]][yy[p]];
  	               if(rs>3)
  	                  continue;
				   int qq,dy,dx;
	               dy=yy[p+1]-yy[p];
                   dx=xx[s+1]-xx[s];
                   rs=0;
				   for(qq=0;qq<cnt_list;qq++)
                   {
                   	   q=list[qq];
               	       if(xx[s]+1<=rec[q].lx&yy[p]+1<=rec[q].ly)
						  rs++;
				   }
                   if(qq>=cnt_list&&rs>=1&&rs<=3&&dx&&dy)
                   {
                   	   for(q=0;q<k;q++)
                   	   {
       	               	   if(rec[q].rx<=xx[i]&&rec[q].lx>=xx[s]+1&&rec[q].ry<=yy[j]&&rec[q].ly>=yy[p]+1)
   	                   	       continue;
                   	       else if(rec[q].rx>=xx[s]+1&&rec[q].lx<=xx[i]&&rec[q].ry>=yy[p]+1&&rec[q].ly<=yy[j])
                   	           break;
   	                   }
   	                   if(q>=k)
   	                   {
   	                   	//  if(i==1&&j==3)
   	                   	  //   printf("s=%d,p=%d,dx=%d,dy=%d,xx=%d,yy=%d\n",s,p,dx,dy,xx[s],yy[p]);
                     	   now+=(long long)dx*(long long)dy;
   	                   }
				   }
   	           }
           }
        //   printf("i=%d,j=%d,now=%I64d,xx=%d,yy=%d\n",i,j,now,xx[i],yy[j]);
           now=(long long)now*(long long)(xx[i+1]-xx[i]);
           now=(long long)now*(long long)(yy[j+1]-yy[j]);
           ans+=now;
       }
       printf("%I64d\n",ans);
	return 0;
}
/*
5 8 1
..******
..******
........
........
........

*/


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
const int inf=1e9;
int xx[400],yy[400];
int cnt_x,cnt_y;
struct rectangle
{
	int lx,ly,rx,ry;
};
rectangle rec[99];
int n,m,k,cnt,mc[111][111],list[99],cnt_list,can_x[200],can_y[200],cx,cy;
bool no[111][111];
long long ans,now;
char str[111][111];
int main()
{
	int i,j,s,p,q,id;
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++)
	   scanf("%s",str[i]);
    cnt=0;
	for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   if(str[i][j]=='*'&&!(i>0&&str[i-1][j]=='*')&&!(j>0&&str[i][j-1]=='*'))
       	   {
  	       	   rec[cnt].lx=i;
  	       	   rec[cnt].ly=j;
  	       	   for(s=i;s<n;s++)
  	       	   {
  	       	      for(p=j;p<m;p++)
  	       	      {
     	       	      if(str[s][p]!='*')
						  break;
     	          }
                  if(p==j)
                     break;
                  rec[cnt].ry=p-1;
  	       	   }
      	       rec[cnt++].rx=s-1;
   	       }
       }
    memset(mc,0,sizeof(mc));
    for(i=0;i<n;i++)
       for(j=0;j<m;j++)
       {
       	   for(s=0;s<k;s++)
		   {
	           if(rec[s].lx<=i&&rec[s].ly<=j)
	                mc[i][j]++;
  		   }
       }
    cnt_x=cnt_y=0;
    for(i=0;i<k;i++)
    {
    	xx[cnt_x++]=rec[i].lx;
    	xx[cnt_x++]=rec[i].rx;
    	if(rec[i].lx-1>=0)
        	xx[cnt_x++]=rec[i].lx-1;
    	if(rec[i].rx+1<n)
 	 	    xx[cnt_x++]=rec[i].rx+1;
    	yy[cnt_y++]=rec[i].ly;
    	yy[cnt_y++]=rec[i].ry;
		if(rec[i].ly-1>=0)
     		yy[cnt_y++]=rec[i].ly-1;
		if(rec[i].ry+1<m)
		    yy[cnt_y++]=rec[i].ry+1;
    }
    sort(xx,xx+cnt_x);
    sort(yy,yy+cnt_y);
    int nn=0;
    for(i=0;i<cnt_x;i++)
    {
    	if(nn==0||xx[nn-1]<xx[i])
    	   xx[nn++]=xx[i];
    }
    cnt_x=nn;
    nn=0;
    for(i=0;i<cnt_y;i++)
    {
    	if(nn==0||yy[nn-1]<yy[i])
    	    yy[nn++]=yy[i];
    }
    cnt_y=nn;
    xx[cnt_x++]=n;
    yy[cnt_y++]=m;
	ans=0;
    for(i=0;i<cnt_x-1;i++)
       for(j=0;j<cnt_y-1;j++)
       {
       	   cnt_list=0;
           for(s=0;s<k;s++)
           {
       	       if(rec[s].rx<=xx[i]&&rec[s].ry<=yy[j])
       	           list[cnt_list++]=s;
		       else if(xx[i]>=rec[s].lx&&xx[i]<=rec[s].rx&&yy[j]>=rec[s].ly&&yy[j]<=rec[s].ry)
           	       break;
		   }
           if(s<k)
               continue;
           now=0;
           int vx,vy;
		   for(s=0;s<=i;s++)
           {
           	   vy=0;
           	   for(p=0;p<=j;p++)
           	   {
   	           	   int rs=mc[xx[i]][yy[j]];
   	           	   if(xx[s])
   	           	      rs-=mc[xx[s]-1][yy[j]];
        	       if(yy[p])
        	          rs-=mc[xx[i]][yy[p]-1];
     	           if(xx[s]&&yy[p])
     	              rs+=mc[xx[s]-1][yy[p]-1];
  	               if(rs>3)
  	                  continue;
				   int qq,dy,dx;
				   if(p==j)
				      dy=1;
	               else
	                  dy=yy[p+1]-yy[p];
                   if(s==i)
                      dx=1;
                   else
                      dx=xx[s+1]-xx[s];
                   rs=0;
				   for(qq=0;qq<cnt_list;qq++)
                   {
                   	   q=list[qq];
               	       if(xx[s]<=rec[q].lx&yy[p]<=rec[q].ly)
               	       {
               	           rs++;
               	           if(xx[s]==rec[q].lx)
               	               dx=1;
           	               if(yy[p]==rec[q].ly)
           	                   dy=1;
               	       }
               	        else if(xx[s]<=rec[q].rx&&xx[s]>=rec[q].lx&&yy[p]<=rec[q].ry&&yy[p]>=rec[q].ly)
           	                break;
				   }
                   if(qq>=cnt_list&&rs>=1&&rs<=3&&dx&&dy)
                   {
                   	   for(q=0;q<k;q++)
                   	   {
   	                   	   if(rec[q].rx<=xx[i]&&rec[q].lx>=xx[s]&&rec[q].ry<=yy[j]&&rec[q].ly>=yy[p])
   	                   	       continue;
                   	       if(rec[q].rx>=xx[s]&&rec[q].lx<=xx[i]&&rec[q].ry>=yy[p]&&rec[q].ly<=yy[j])
                   	           break;
   	                   }
   	                   if(q>=k)
                     	   now+=(long long)dx*(long long)dy;
				   }
   	           }
           }
           now=(long long)now*(long long)(xx[i+1]-xx[i]);
           now=(long long)now*(long long)(yy[j+1]-yy[j]);
           ans+=now;
       }
       printf("%I64d\n",ans);
	return 0;
}