#include<iostream>
#include<string.h>

using namespace std;

int w,h;
char field[50][50];
bool check[50][50];
int dx[] = {-1,0,1,0},dy[] = {0,-1,0,1};
int sum = 0;
bool black = false,white = false;

void bfs(int x,int y);

int main(){
	while(true){
		cin >> w >> h;
		if(w == 0 && h == 0) break;
		memset(field,0,sizeof(field));
		memset(check,0,sizeof(check));
		
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				cin >> field[i][j];
			}
		}
		
		int b_sum = 0,w_sum = 0;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				sum = 0;
				black = false;
				white = false;
				if(check[i][j] == false && field[i][j] == '.'){
					bfs(j,i);
				}
				if(black && !white){
					b_sum += sum;
				}else if(!black && white){
					w_sum += sum;
				}
			}
		}
		
		cout << b_sum << " " << w_sum << endl;
	}
	return 0;
}

void bfs(int x,int y){
	check[y][x] = true;
	sum++;
	for(int i = 0;i < 4;i++){
		if(0 <= x + dx[i] && x + dx[i] < w && 0 <= y + dy[i] && y + dy[i] < h){
			if(field[y + dy[i]][x + dx[i]] == 'B'){
				black = true;
			}else if(field[y + dy[i]][x + dx[i]] == 'W'){
				white = true;
			}
		}
	}
	for(int i = 0;i < 4;i++){
		if(0 <= x + dx[i] && x + dx[i] < w && 0 <= y + dy[i] && y + dy[i] < h && check[y + dy[i]][x + dx[i]] == false && field[y + dy[i]][x + dx[i]] == '.'){
			bfs(x + dx[i],y + dy[i]);
		}
	}
}
