#include <iostream>
using namespace std;

char field[50][50];
bool used[50][50];
int height, width;
int b_count, w_count;
bool b, w;

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

int move(int i, int j){
	int count = 1;
	used[i][j] = true;
	for(int k = 0; k < 4; k++){
		if(i+dy[k] >= 0 && i+dy[k] < height &&
		   j+dx[k] >= 0 && j+dx[k] < width)
		{
			int i2 = i+dy[k], j2 = j+dx[k];
			if(field[i2][j2] == '.'){
				if(!used[i2][j2]) count += move(i2, j2);
			}else if(field[i2][j2] == 'B'){
				b = true;
			}else{
				w = true;
			}
		}
	}
	return count;
}
	

int main(){
	while(cin >> width >> height && (width || height)){
		for(int i = 0; i < height; i++){
			for(int j = 0; j < width; j++){
				cin >> field[i][j];
				used[i][j] = false;
			}
		}
		b_count = 0;
		w_count = 0;
		for(int i = 0; i < height; i++){
			for(int j = 0; j < width; j++){
				if(field[i][j] == '.' && !used[i][j]){
					b = false;
					w = false;
					int count = move(i, j);
					if(b && !w){
						b_count += count;
					}else if(w && !b){
						w_count += count;
					}
				}
			}
		}
		cout << b_count << " " << w_count << endl;
	}
	return 0;
}