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 JAVA):

Solution:

import java.util.Arrays;
import java.util.Scanner;

public class Main {

    int H, W;
    int[][] B;
    int[] dx = {-1, 0, 1, 0};
    int[] dy = {0, -1, 0, 1};
    int BLACK = 0, WHITE = 1, VISITED = 2;

    void run() {
        Scanner sc = new Scanner(System.in);

        H = sc.nextInt();
        W = sc.nextInt();
        B = new int[H + 2][W + 2];

        Arrays.fill(B[0], VISITED);
        Arrays.fill(B[H + 1], VISITED);

        for (int i = 1; i <=H; i++) {
            Arrays.fill(B[i], VISITED);
            String l = sc.next();
            for (int j = 0; j < W; j++) {
                B[i][j + 1] = l.charAt(j) == '#' ? BLACK : WHITE;
            }
        }

        long ans = 0;
        for (int y = 1; y <= H; y++) for (int x = 1; x <= W; x++) {
            P c = solve(x, y);
            ans += 1L * c.bl * c.wh;
        }

        System.out.println(ans);
    }

    P solve(int x, int y) {
        int cell = B[y][x];
        B[y][x] = VISITED;

        P p = new P(0, 0);
        if (cell == BLACK) {
            p.bl += 1;
        } else if (cell == WHITE) {
            p.wh += 1;
        }

        for (int i = 0; i < 4; i++) if (B[y + dy[i]][x + dx[i]] == 1 - cell) {
            P next = solve(x + dx[i], y + dy[i]);
            p.bl += next.bl;
            p.wh += next.wh;
        }

        return p;
    }

    class P {
        int bl, wh;
        P(int bl, int wh) {
            this.bl = bl;
            this.wh = wh;
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}