#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
char bw[] = {'B', 'W'};

struct STATE { int x, y, t; };

char pile[52][52];
int terr[52][52];

void init()
{
	for (int i = 0; i < 52; i++){
		for (int j = 0; j < 52; j++){
			pile[i][j] = 0;
			terr[i][j] = 0;
		}
	}
}

int main()
{
	int w, h;
	while (scanf("%d %d", &w, &h), w + h){
		init();
		
		for (int i = 1; i <= h; i++){
			for (int j = 1; j <= w; j++){
				scanf(" %c", &pile[i][j]);
			}
		}
		
		queue<STATE> que;
		for (int t = 0; t <= 1; t++){
			for (int i = 1; i <= h; i++){
				for (int j = 1; j <= w; j++){
					if (pile[i][j] == bw[t]){
						for (int dir = 0; dir < 4; dir++){
							int tx = i + dx[dir];
							int ty = j + dy[dir];
							if (pile[tx][ty] == '.'){
								que.push( {tx, ty, t} );
							}
						}
					}
				}
			}
		}
		
		while (!que.empty()){
			STATE st = que.front(); que.pop();
			if (terr[st.x][st.y] & (1 << st.t)) continue;
			terr[st.x][st.y] |= (1 << st.t);
			for (int dir = 0; dir < 4; dir++){
				int tx = st.x + dx[dir];
				int ty = st.y + dy[dir];
				if (pile[tx][ty] == '.' && !(terr[tx][ty] & (1 << st.t))){
					que.push( {tx, ty, st.t} );
				}
			}
		}
		
		int cnt[2] = {0};
		for (int t = 0; t <= 1; t++){
			for (int i = 1; i <= h; i++){
				for (int j = 1; j <= w; j++){
					cnt[t] += !(terr[i][j] ^ (1 << t));
				}
			}
		}
		
		printf("%d %d\n", cnt[0], cnt[1]);
	}
	
	return 0;
}