#include <iostream>
#include <vector>

using namespace std;

int W, H;
vector<string> m;
vector<string> m2;

int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};

void paint(int x, int y, char c) {
	if (x < 0 || x >= W || y < 0 || y >= H) return;

	char c2 = c-'A'+'a';
	if (m[y][x] == '.') {
		m[y][x] = c2;
	}
	else if (m[y][x] == 'W' || m[y][x] == 'B') return;
	else if (m[y][x] == '#') return;
	else if (m[y][x] == c2) return;
	else m[y][x] = '#';

	for (int d = 0; d < 4; ++d) {
		paint(x+dx[d], y+dy[d], c);
	}
}

int main() {
	while ( cin >> W >> H, W || H ) {
		m.resize(H);
		for (int y = 0; y < H; ++y) {
			cin >> m[y];
		}
		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				if (m[y][x] == 'W' || m[y][x] == 'B') {
					for (int d = 0; d < 4; ++d) {
						paint(x+dx[d], y+dy[d], m[y][x]);
					}
				}
			}
		}
		int w = 0, b = 0;
		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				if (m[y][x] == 'w') ++w;
				if (m[y][x] == 'b') ++b;
			}
		}
		cout << b << " " << w << endl;
	}
}