#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

bool between(int a, int b, int c){
	return a <= b && b < c;
}

void paint(
	int x, int y, const vector<string> &field,
	vector< vector<int> > &canvas)
{
	const int W = field[0].size(), H = field.size();
	if(!between(0, x, W) || !between(0, y, H)){ return; }
	if(field[y][x] != '.' || canvas[y][x]){ return; }
	canvas[y][x] = 1;
	for(int i = 0; i < 4; ++i){
		paint(x + dx[i], y + dy[i], field, canvas);
	}
}

int main(){
	while(true){
		int w, h;
		cin >> w >> h;
		if(w == 0 && h == 0){ break; }
		vector<string> field(h);
		for(int i = 0; i < h; ++i){ cin >> field[i]; }
		vector< vector<int> > white(h, vector<int>(w));
		vector< vector<int> > black(h, vector<int>(w));
		for(int y = 0; y < h; ++y){
			for(int x = 0; x < w; ++x){
				for(int i = 0; i < 4; ++i){
					if(field[y][x] == 'W'){
						paint(x + dx[i], y + dy[i], field, white);
					}else if(field[y][x] == 'B'){
						paint(x + dx[i], y + dy[i], field, black);
					}
				}
			}
		}
		int wsum = 0, bsum = 0;
		for(int y = 0; y < h; ++y){
			for(int x = 0; x < w; ++x){
				if(white[y][x] == black[y][x]){ continue; }
				if(white[y][x]){ ++wsum; }
				if(black[y][x]){ ++bsum; }
			}
		}
		cout << bsum << " " << wsum << endl;
	}
	return 0;
}