class BipartiteMatching: def __init__(self, n, m): self.size = n + m self._n = n self._g = [[] for _ in range(n)] self.matchA = [-1] * n self.matchB = [-1] * m def add_edge(self, u, v): self._g[u].append(v) def dfs(self, v): self.used[v] = True for u in self._g[v]: w = self.matchB[u] if w < 0 or not self.used[w] and self.dfs(w): self.matchA[v] = u self.matchB[u] = v return True return False def bipartite_matching(self): res = 0 for v in range(self._n): if self.matchA[v] < 0: self.used = [0] * self._n if self.dfs(v): res += 1 return res import sys input = sys.stdin.readline n, m = map(int, input().split()) s = [input() for _ in range(n)] bm = BipartiteMatching(n * m // 2 + 1, n * m // 2) b, w = 0, 0 for i in range(n): for j in range(m): if s[i][j] == ".": continue if s[i][j] == "b": b += 1 else: w += 1 if (i + j) % 2: if j < m - 1: if s[i][j + 1] != ".": bm.add_edge((i * m + j + 1) // 2, (i * m + j) // 2) if i < n - 1: if s[i + 1][j] != ".": bm.add_edge(((i + 1) * m + j) // 2, (i * m + j) // 2) else: if j < m - 1: if s[i][j + 1] != ".": bm.add_edge((i * m + j) // 2, (i * m + j + 1) // 2) if i < n - 1: if s[i + 1][j] != ".": bm.add_edge((i * m + j) // 2, ((i + 1) * m + j) // 2) match = bm.bipartite_matching() b -= match w -= match k = min(b, w) print(100 * match + 10 * k + (b + w - k - k))