import java.util.*; public class Main { public static void main (String[] args) throws Exception { Scanner sc = new Scanner(System.in); int h = sc.nextInt(); int w = sc.nextInt(); char[][] field = new char[h + 2][]; int bCount = 0; int wCount = 0; for (int i = 0; i <= h + 1; i++) { if (i == 0 || i == h + 1) { field[i] = new char[w + 2]; Arrays.fill(field[i], '.'); continue; } field[i] = ("." + sc.next() + ".").toCharArray(); for (int j = 1; j <= w; j++) { if (field[i][j] == 'w') { wCount++; } else if (field[i][j] == 'b') { bCount++; } } } int[][] counts = new int[h + 2][w + 2]; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { if (field[i][j] != '.') { if (field[i - 1][j] != '.') { counts[i][j]++; } if (field[i + 1][j] != '.') { counts[i][j]++; } if (field[i][j - 1] != '.') { counts[i][j]++; } if (field[i][j + 1] != '.') { counts[i][j]++; } } } } boolean flag = true; int point = 0; while (flag) { flag = false; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { if (counts[i][j] == 1) { if (counts[i - 1][j] > 0) { counts[i - 1][j] = 0; counts[i][j] = 0; counts[i - 2][j]--; counts[i - 1][j - 1]--; counts[i - 1][j + 1]--; wCount--; bCount--; flag = true; point += 100; break; } if (counts[i + 1][j] > 0) { counts[i][j] = 0; counts[i + 1][j] = 0; counts[i + 2][j]--; counts[i + 1][j - 1]--; counts[i + 1][j + 1]--; wCount--; bCount--; flag = true; point += 100; break; } if (counts[i][j - 1] > 0) { counts[i][j] = 0; counts[i][j - 1] = 0; counts[i][j - 2]--; counts[i - 1][j - 1]--; counts[i + 1][j - 1]--; wCount--; bCount--; flag = true; point += 100; break; } if (counts[i][j + 1] > 0) { counts[i][j] = 0; counts[i][j + 1] = 0; counts[i][j + 2]--; counts[i - 1][j + 1]--; counts[i + 1][j + 1]--; wCount--; bCount--; flag = true; point += 100; break; } } } } } int allCount = 0; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { if (counts[i][j] > 0) { allCount++; } } } point += allCount / 2 * 100; bCount -= allCount / 2; wCount -= allCount / 2; int max = Math.max(wCount, bCount); int min = Math.min(wCount, bCount); point += 10 * min; point += max - min; System.out.println(point); } }