#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
using namespace std;
typedef pair<int ,int > P;
int xs[] = {-1, 0, 1, 0}, ys[] = {0, 1, 0, -1};
char a[55][55];
int w, h;
bool b[55][55], wh[55][55];
 
int main(){
	while(cin >> w >> h, w | h){
		memset(b, 0, sizeof(b));
		memset(wh, 0, sizeof(wh));
		queue<P> black, white;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				cin >> a[i][j];
				if(a[i][j] == 'B')black.push(P(i, j));
				if(a[i][j] == 'W')white.push(P(i, j));
			}
		}
		while(!black.empty()){
			for(int t = black.size() - 1;t >= 0;t--){
				P tmp = black.front();black.pop();
				for(int i = 0;i < 4;i++){
					int nx = tmp.first + xs[i], ny = tmp.second + ys[i];
					if(nx < 0 || nx >= h || ny < 0 || ny >= w || a[nx][ny] != '.')continue;
					if(b[nx][ny])continue;
					b[nx][ny] = true;
					black.push(P(nx, ny));
				}
			}
		}
		while(!white.empty()){
			for(int t = white.size() - 1;t >= 0;t--){
				P tmp = white.front();white.pop();
				for(int i = 0;i < 4;i++){
					int nx = tmp.first + xs[i], ny = tmp.second + ys[i];
					if(nx < 0 || nx >= h || ny < 0 || ny >= w || a[nx][ny] != '.')continue;
					if(wh[nx][ny])continue;
					wh[nx][ny] = true;
					white.push(P(nx, ny));
				}
			}
		}
		int bc = 0, wc = 0;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				if(b[i][j] && !wh[i][j])bc++;
				if(!b[i][j] && wh[i][j])wc++;
			}
		}
		cout << bc << " " << wc << endl;
	}
	return 0;
}