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 sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [H, W] = [long(input_raw[0]), long(input_raw[1])]
    S = []
    for i in range(H):
        input_raw = read_func().strip()
        S.append(input_raw)

    move_list = [(0,1),(1,0),(0,-1),(-1,0)]
    is_visited = set([])
    count = 0
    for i in range(H):
        for j in range(W):
            path_list = [(i, j)]
            if (i, j) not in is_visited:
                is_visited.add((i, j))

                q = deque([(i, j)])
                while len(q) > 0:
                    nd = q.popleft()
                    for move in move_list:
                        new_i = nd[0] + move[0]
                        new_j = nd[1] + move[1]
                        if new_i >= 0 and new_j >= 0 and new_i < H and new_j < W:
                            if (new_i, new_j) not in is_visited:
                                if S[nd[0]][nd[1]] != S[new_i][new_j]:
                                    path_list.append((new_i, new_j))
                                    is_visited.add((new_i, new_j))
                                    q.append((new_i, new_j))
            black_num = 0
            white_num = 0
            for path in path_list:
                if S[path[0]][path[1]] == "#":
                    black_num += 1
                else:
                    white_num += 1
            count +=black_num *white_num

    print count



if __name__ == '__main__':
    main()
