#include <iostream>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int dx[] = {1,-1,0,0};
const int dy[] = {0,0,-1,1};
int w,h;
char data[50][50];
struct P{int x,y,d;};
int correct(int x,int y){
	return x >= 0 && y >= 0 && x < w && y < h;
}

int solve(int x,int y){
	queue<P> Q;
	bool done[50][50] = {0};
	int chk = 0;
	P t = {x,y,0};
	Q.push(t);
	while(Q.size()){
		P q = Q.front(); Q.pop();
		if(done[q.y][q.x])continue;
		else done[q.y][q.x] = true;
		
		if(data[q.y][q.x] != '.'){
			if(data[q.y][q.x] == 'B') chk |= 1;
			else chk |= 2;
			continue;
		}
		rep(i,4){
			P nxt = {q.x+dx[i] , q.y+dy[i], q.d+1};
			if(correct(nxt.x,nxt.y))Q.push(nxt);
		}
	}
	if(chk == 1)return 0;
	else if(chk == 2)return 1;
	else return 2;
}
int main(){
	while(cin >> w >> h , w ){
		int ret[3] = {0};
		rep(i,h)rep(j,w)cin >> data[i][j];
		rep(i,h)rep(j,w)
			if(data[i][j] == '.')ret[solve(j,i)]++;
		
		cout << ret[0] << " " << ret[1] << endl;
	}
}