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
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()


int fie[404][404];

int d[] = {1,-1,0,0};

#define int long long


int H,W;
void dfs(int x,int y,int c, pair<int,int>& p) {
  if(x < 0 || H <= x) return;
  if(y < 0 || W <= y) return;
  if(fie[x][y] == -1) return;
  if(fie[x][y] != c) return;
  fie[x][y] = -1;
  if(c == 0) p.first++;
  else p.second++;
  for(int dd = 0;dd < 4;dd++) {
    int i = x + d[dd];
    int j = y + d[dd ^ 2];
    dfs(i,j,c ^ 1 , p);
  } 
}

signed main() {
  cin >> H >> W;
  rep(i,0,H - 1) {
    string s;
    cin >> s;
    rep(j,0,W - 1) {
      if(s[j] == '.') fie[i][j] = 1;
    }
  }

  int ans = 0;

  for(int i = 0;i < H;i++) {
    for(int j = 0;j < W;j++) {
      if(fie[i][j] != -1) {
        pair<int,int> p = {0,0};
        dfs(i,j,fie[i][j],p);
        ans += p.first * p.second;
      }
    }
  }
  cout << ans << endl;
}
