#include <iostream>
#include <string>
using namespace std;

int w,h;
string field[50];
int wb[2][50][50];

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

void dfs(int x,int y,int num){
	for(int i = 0;i < 4;i++){
		int nx = x + dx[i],ny = y + dy[i];
		if(nx >= 0 && nx < h && ny >= 0 && ny < w && field[nx][ny] == '.' && !wb[num][nx][ny]){
			wb[num][nx][ny] = 1;
			dfs(nx,ny,num);
		}
	}
}

int main(){
	while(cin >> w >> h,w){
		for(int i = 0;i < h;i++) cin >> field[i];
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				wb[0][i][j] = 0;
				wb[1][i][j] = 0;
			}
		}
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				if(field[i][j] == 'W') dfs(i,j,1);
				else if(field[i][j] == 'B') dfs(i,j,0);
			}
		}
		int a = 0,b = 0;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				if(wb[0][i][j] && !wb[1][i][j]) a++;
				else if(wb[1][i][j] && !wb[0][i][j]) b++;
			}
		}
		cout << a << " " << b << endl;
	}
}