// AOJ 2014: Surrounding Area
// 2017.10.1

#include <stdio.h>
#include <string.h>

typedef struct { int r, c; } Q;
Q q[2700]; int top;

char map[52][52]; int w, h;
char visited[50][52];

int mv[4][2] = { {-1,0},{0,1},{1,0},{0,-1} };

void calc(int *sb, int *sw)
{
	int i, f, r, c, r1, c1, r2, c2, sum;

	*sb = *sw = 0;
	memset(visited, 0, sizeof(visited));
	for (r = 0; r < h; r++) for (c = 0; c < w; c++) {
		if (map[r][c] != '.' || visited[r][c]) continue;

		f = 0, sum = 1, visited[r][c] = 1;
		q[0].r = r, q[0].c = c, top = 1;
		while (top > 0) {
			r1 = q[--top].r, c1 = q[top].c;
			for (i = 0; i < 4; i++) {
				r2 = r1 + mv[i][0], c2 = c1 + mv[i][1];
				if (r2 < 0 || r2 >= h || c2 < 0 || c2 >= w || visited[r2][c2]) continue;
				if      (map[r2][c2] == 'B') f |= 1;
				else if (map[r2][c2] == 'W') f |= 2;
				else {
					visited[r2][c2] = 1; sum++;
					q[top].r = r2, q[top++].c = c2;
				}
			}
		}
		if      (f == 1) *sb += sum;
		else if (f == 2) *sw += sum;
	}
}

int main()
{
	int r, c, sb, sw;

	while (scanf("%d%d", &w, &h) && w > 0) {
		for (sb = sw = 0, r = 0; r < h; r++) {
			scanf("%s", map[r]);
			for (c = 0; c < w; c++) {
				if (map[r][c] == 'B') sb++;
				else if (map[r][c] == 'W') sw++;
			}
		}
		if (!sb && !sw) puts("0 0");
		else if (!sb) printf("0 %d\n", w*h - sw);
		else if (!sw) printf("%d 0\n", w*h - sb);
		else { calc(&sb, &sw); printf("%d %d\n", sb, sw); }
	}
	return 0;
}