Problem: There is a grid with H rows and W columns, where each square is painted black or white.

You are given H strings S_1, S_2, ..., S_H, each of length W. If the square at the i-th row from the top and the j-th column from the left is painted black, the j-th character in the string S_i is `#`; if that square is painted white, the j-th character in the string S_i is `.`.

Find the number of pairs of a black square c_1 and a white square c_2 that satisfy the following condition:

* There is a path from the square c_1 to the square c_2 where we repeatedly move to a vertically or horizontally adjacent square through an alternating sequence of black and white squares: black, white, black, white...

Constraints

* 1 \leq H, W \leq 400
* |S_i| = W (1 \leq i \leq H)
* For each i (1 \leq i \leq H), the string S_i consists of characters `#` and `.`.

Input

Input is given from Standard Input in the following format:


H W
S_1
S_2
:
S_H


Output

Print the answer.

Examples

Input

3 3
.#.
..#
#..


Output

10


Input

3 3
.#.
..#
..


Output

10


Input

2 4
....
....


Output

0


Input

4 3


...


Output

6

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll maxn=400;
ll h,w,s1,s2;
string s[maxn];
bool vis[maxn][maxn];

void dfs(ll i,ll j,char c){
    //cout<<i<<" "<<j<<endl;
    if(vis[i][j]) return;
    if(i==h||j==w||i<0||j<0) return ; 
    if(c=='#'){
        if(s[i][j]=='#') return ;
    }
    if(c=='.'){
        if(s[i][j]=='.') return ;
    }
    vis[i][j]=true;
    if(s[i][j]=='#') s1++;
    else s2++;
    dfs(i+1,j,s[i][j]);
    dfs(i,j+1,s[i][j]);
    dfs(i-1,j,s[i][j]);
    dfs(i,j-1,s[i][j]);

}

int main(){

cin>>h>>w;
memset(vis,false,sizeof(vis));
ll ans=0;
for(ll i=0;i<h;i++) cin>>s[i];
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){

            if(!vis[i][j]){
            //    cout<<i<<" "<<j<<endl;
                s1=0;s2=0;
                if(s[i][j]=='#')
                dfs(i,j,'.');
                else
                dfs(i,j,'#');
               // cout<<s1<<" "<<s2<<endl;
                ans+=s1*s2;
            }
        }
    }
    cout<<ans;
    return 0;
}