#include <iostream>
#include <algorithm>
#include <string>
#include <climits>

#define INF INT_MAX>>1 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

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

int w, h;
int white, black;
int tmp_count;
char tmp_color;
char a[55][55];

void dfs(int y, int x){
	if(y<0 || h<=y || x<0 || w<=x) return;
	if(a[y][x] == '*') return;
	if(a[y][x] == 'W' || a[y][x] == 'B'){
		if(tmp_color == NULL) tmp_color = a[y][x];
		else if(tmp_color != a[y][x]) tmp_count = -INF;
		return;
	}

	a[y][x] = '*';
	tmp_count++;
	rep(i, 4){
		dfs(y+dy[i], x+dx[i]);
	}
}

int main(void){
	while(1){
		cin >> w >> h;
		if(!w && !h) break;
	
		fill(a[0], a[54], '\0');
		rep(i, h){
			cin >> a[i];
		}

		white = black = 0;
		rep(i, h){
			rep(j, w){
				tmp_count = 0;
				tmp_color = NULL;
				if(a[i][j] == '.'){
					dfs(i, j);
					if(0 < tmp_count){
						if(tmp_color == 'W') white += tmp_count;
						else if(tmp_color == 'B') black += tmp_count;
					}
				}
			}
		}
		cout << black << " " << white << endl;
	}
	return 0;
}
