#include<iostream>
#include<stack>
#include<algorithm>

using namespace std;

typedef pair<int, int> P;

int W, H;
int vx[4] = { 0,-1,0,1 }, vy[4] = { 1,0,-1,0 };
int filed[50][50];
bool usedB[50][50], usedW[50][50];

void dfs(P start, int flg) {
	stack<P> s;
	s.push(start);
	
	while (s.size()) {
		auto now = s.top(); s.pop();
		for (int i = 0; i < 4; i++) {
			int nx = now.first + vx[i], ny = now.second + vy[i];
			if (nx < 0 || ny < 0 || nx >= H || ny >= W)continue;
			if (!flg) {
				if (usedW[nx][ny])continue;
				if (filed[nx][ny] != 0)continue;
				usedW[nx][ny] = true;
				s.push(P(nx, ny));
			}else {
				if (usedB[nx][ny])continue;
				if (filed[nx][ny] != 0)continue;
				usedB[nx][ny] = true;
				s.push(P(nx, ny));
			}
		}
	}
}

int main() {
	
	while (1) {
		cin >> W >> H;
		if (W + H == 0)break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				char c;
				cin >> c;
				if (c == 'W')filed[i][j] = 1;
				else if (c == 'B')filed[i][j] = 2;
				else filed[i][j] = 0;
				usedB[i][j] = false;
				usedW[i][j] = false;
			}
		}

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (filed[i][j] == 1) {
					dfs(P(i, j), 0);
				}
				else if (filed[i][j] == 2) {
					dfs(P(i, j), 1);
				}
			}
		}

		int ansB = 0, ansW = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (usedW[i][j] && !usedB[i][j])ansW++;
				if (usedB[i][j] && !usedW[i][j])ansB++;
			}
		}
		cout << ansB << " " << ansW << endl;

	}
	return 0;
}
