You are given a *n* × *m* field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle).
The first line contains two positive integer numbers *n* and *m* (1 ≤ *n*, *m* ≤ 1000). The following *n* lines consist of *m* characters each, describing the field. Only '.' and '*' are allowed.
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m,ans=0;
    cin >> n >> m;
    char mp[n][m];
    int  r[n], c[m];
    memset(r,0,sizeof(r));
    memset(c,0,sizeof(c));

    for(int i=0;i<n;i++){
        cin >> mp[i];
        for(int j=0;j<m;j++)
            if(mp[i][j] == '*'){
                r[i]++;
                c[j]++;
            }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++)
            if(mp[i][j] == '*') ans+=(r[i]-1)*(c[j]-1);
    }
    cout << ans << '\n';
}
