N,M = list(map(int, input().split(' '))) C = [] for _ in range(N): blocks = input() choco = [] for block in blocks: choco.append(block) C.append(choco) W = 0 B = 0 DX = [0, -1, 0, 1] DY = [-1, 0, 1, 0] def dfs(x,y): global W global B if C[x][y] == 'w': W = W + 1 elif C[x][y] == 'b': B = B + 1 C[x][y] = '.' for i in range(len(DX)): nx = x + DX[i] ny = y + DY[i] if 0 <= nx and nx < N and 0 <= ny and ny < M \ and (C[nx][ny] == 'w' or C[nx][ny] == 'b'): dfs(nx,ny) wbs = [] for i in range(N): for j in range(M): if C[i][j] != '.': W = 0 B = 0 dfs(i,j) wbs.append([W,B]) rows = 0 for wb in wbs: while 0 < wb[0] and 0 < wb[1]: wb[0] = wb[0] - 1 wb[1] = wb[1] - 1 rows = rows + 1 total_w = 0 total_b = 0 for wb in wbs: total_w = total_w + wb[0] total_b = total_b + wb[1] pairs = 0 while 0 < total_w and 0 < total_b: total_w = total_w - 1 total_b = total_b - 1 pairs = pairs + 1 print(rows * 100 + pairs * 10 + total_w + total_b)