#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> mypair;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
void dfs(vector<vector<bool> > &map,set<mypair> &ans,mypair now){
	int x = now.first;
	int y = now.second;
	map[x][y] = false;
	for(int i=0;i<4;i++){
	int nx = x+dx[i];
	int ny = y+dy[i];
	if(map[nx][ny]){
		mypair next = mypair(nx,ny);
		ans.insert(next);
		dfs(map,ans,next);
	}
	}
	return ;
}

int main(){
	while(1){
	int w,h;
	cin>>w>>h;
	if(w==0)break;
	vector<vector<bool> > mapb(h+2,vector<bool>(w+2,false) ) ,mapw(h+2,vector<bool>(w+2,false) );
	vector<mypair> brack,white;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
		{
			char a;
			cin>>a;
			if(a=='.'){
				mapb[i][j] = true;
				mapw[i][j] = true;
			}else if(a=='W')white.push_back(mypair(i,j) );
			else brack.push_back(mypair(i,j) );
		}
	set<mypair> ansb,answ;
	for(int i=0;i<brack.size();i++)dfs(mapb,ansb,brack[i]);
	for(int i=0;i<white.size();i++)dfs(mapw,answ,white[i]);
	int cntb=0,cntw=0;
	for(auto i:ansb){
		auto it = answ.find(i);
		if(it==answ.end())cntb++;
	}
	for(auto i:answ){
		auto it = ansb.find(i);
		if(it==ansb.end())cntw++;
	}
	cout<<cntb<<' '<<cntw<<endl;
	}

	return 0;
}

