#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};
const int W = 1;
const int B = 2;
int w, h;
vector<vector<int> > label;

void dfs(int x, int y, int who) {
	label[y][x] |= who;
	for(int i = 0; i < 4; ++i) {
		const int nx = x + dx[i], ny = y + dy[i];
		if(nx < 0 || ny < 0 || nx >= w || ny >= h)
			continue;

		if(!(label[ny][nx] & who))
			dfs(nx, ny, who);
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	while(cin >> w >> h, w) {
		vector<string> field(h);
		for(int i = 0; i < h; ++i)
			cin >> field[i];

		label.clear();
		label.resize(h, vector<int>(w, 0));
		for(int i = 0; i < h; ++i)
			for(int j = 0; j < w; ++j)
				if(field[i][j] != '.')
					label[i][j] = (W | B);

		for(int i = 0; i < h; ++i)
			for(int j = 0; j < w; ++j)
				if(field[i][j] == 'W')
					dfs(j, i, W);
				else if(field[i][j] == 'B')
					dfs(j, i, B);

		int num_b = 0, num_w = 0;
		for(int i = 0; i < h; ++i)
			for(int j = 0; j < w; ++j)
				if(label[i][j] == W)
					++num_w;
				else if(label[i][j] == B)
					++num_b;
					
		cout << num_b << " " << num_w << endl;
	}

	return EXIT_SUCCESS;
}