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
import java.util.*;
import static java.lang.System.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int h=sc.nextInt();
        int w=sc.nextInt();
        char[][] f=new char[h][w];
        for (int i = 0; i < h; i++) {
            f[i]=sc.next().toCharArray();
        }
        UF.init();
        int[] dx={-1,0,1,0};
        int[] dy={0,-1,0,1};
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                int p=w*i+j;
                for (int k = 0; k < 4; k++) {
                    int x=j+dx[k];
                    int y=i+dy[k];
                    if(r(h,w,x,y)){
                        if(f[i][j]!=f[y][x]){
                            UF.unite(p,y*w+x);
                        }
                    }
                }
            }
        }
        long[] white=new long[w*h];
        long[] black=new long[w*h];
        long ans=0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                int p=i*w+j;
                if(f[i][j]=='.')white[UF.root(p)]++;
                else black[UF.root(p)]++;
            }
        }
        for (int i = 0; i < w*h; i++) {
            ans+=white[i]*black[i];
        }
        out.println(ans);
    }
    static boolean r(int h,int w,int x,int y){
        return 0<=x&&x<w&&0<=y&&y<h;
    }
    static class UF{
        static int size=400*400;
        static int[] par=new int[size];
        //初期化
        static void init(){
            for (int i = 1; i <size ; i++) {
                par[i]=i;
            }
        }
        //根をたどる
        static int root(int x){
            if(par[x]==x){
                return x;
            }else{
                return par[x]=root(par[x]);
            }
        }
        //同じ根をもつか(同じ集合に属するか)判定
        static boolean same(int x,int y){
            return root(x)==root(y);
        }
        //合体
        static void unite(int x,int y){
            x=root(x);
            y=root(y);
            if(x==y)return;
            par[x]=y;
        }
    }
}