#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int w, h;
char a[50][50];
int BW[50][50];
int dx[] = { 1,0,0,-1 }, dy[] = { 0,1,-1,0 };

void dfs(int x, int y, int flag) {
	for (int i = 0; i < 4; ++i) {
		int nx = x + dx[i], ny = y + dy[i];
		if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
		if (a[nx][ny] != '.') continue;
		if (BW[nx][ny] & flag) continue;
		BW[nx][ny] |= flag;
		dfs(nx, ny, flag);
	}
}

int main() {
	while (cin >> w >> h, w) {
		memset(BW, 0, sizeof(BW));
		for (int i = 0; i < h; ++i)
			for (int j = 0; j < w; ++j)
				cin >> a[i][j];
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				if (a[i][j] == 'B') dfs(i, j, 1);
				else if (a[i][j] == 'W') dfs(i, j, 2);
			}
		}
		int cntb = 0, cntw = 0;
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				if (BW[i][j] == 1) cntb++;
				else if (BW[i][j] == 2) cntw++;
			}
		}
		cout << cntb << " " << cntw << endl;
	}

	return 0;
}
