#include "iostream"
#include "vector"
#include "string"
#include "cstring"
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool black[50][50],white[50][50];
string in[50];
bool used[50][50];
int w,h;

void dfs(int y,int x,int f)
{
	if(f==1) white[y][x]=true;
	else black[y][x]=true;
	used[y][x]=true;
	for (int i = 0; i < 4; i++) {
		int nx=x+dx[i],ny=y+dy[i];
		if(0<=nx&&nx<w&&0<=ny&&ny<h&&!used[ny][nx]&&in[ny][nx]=='.')
			dfs(ny,nx,f);
	}
}

int main(void)
{
	while (cin>>w>>h,w) {
		memset(black,0,sizeof(black));
		memset(white,0,sizeof(white));
		for (int i = 0; i < h; i++) {
			cin>>in[i];
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				int f=0;
				if(in[i][j]=='W') f=1;
				else if(in[i][j]=='B') f=2;

				if(in[i][j]!='.')
				{
					memset(used,0,sizeof(used));
					dfs(i,j,f);
				}
			}
		}

		int Black=0,White=0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if(in[i][j]!='B'&&black[i][j]&&!white[i][j]) Black++;
				else if(in[i][j]!='W'&&!black[i][j]&&white[i][j]) White++;
			}
		}
		cout<<Black<<" "<<White<<endl;
	}
	return 0;
}