#include <iostream>
#include <cstring>

using namespace std;

void fill(char map[55][55], int x, int y, char c){
	if(map[x][y] == '.'){
		map[x][y] = c;
		fill(map, x+1, y,c);
		fill(map, x-1, y,c);
		fill(map, x, y+1,c);
		fill(map, x, y-1,c);
	}
}

int main(){
	int w,h;
	cin >> w >> h;
	while(w&&h){
		char mapb[55][55];
		memset(mapb, -1, sizeof mapb);
		for(int i = 0 ; i < h; ++i){
			for(int j = 0; j < w; ++j){
				cin >> mapb[i+1][j+1];
			}
		}
		char mapw[55][55];
		memcpy(mapw, mapb, sizeof mapb);
		for(int i = 1; i <= h; ++i){
			for(int j = 1; j <= w; ++j){
				if(mapb[i][j] == 'B'){
					fill(mapb, i+1, j,'b');
					fill(mapb, i-1, j,'b');
					fill(mapb, i, j+1,'b');
					fill(mapb, i, j-1,'b');
				}
				if(mapw[i][j] == 'W'){
					fill(mapw, i+1, j,'w');
					fill(mapw, i-1, j,'w');
					fill(mapw, i, j+1,'w');
					fill(mapw, i, j-1,'w');
				}
			}
		}
		int nb,nw;
		nw = nb = 0;
		for(int i = 0; i < 55; ++i){
			for(int j = 0; j < 55; ++j){
				if(mapb[i][j] == 'b' && mapw[i][j] == '.'){
					nb++;
				}
				if(mapw[i][j] == 'w' && mapb[i][j] == '.'){
					nw++;
				}
			}
		}
		cout << nb << " " << nw << endl;
		cin >> w >> h;
	}
}