#include <iostream>
#include <string>
#include <string.h>

#define W_MAX 52
#define H_MAX 52

int f[H_MAX][W_MAX];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

void dfs1(int x,int y);
void dfs2(int x,int y);

using namespace std;

int main(void)
{
	int w,h;
	char c;
	int i1,i2;
	int count1,count2;

	while(1){
		cin >> w >> h;
		if(w+h==0) break;

		memset(f,-1,sizeof(f));

		for(i1=1;i1<=h;i1++){
			for(i2=1;i2<=w;i2++){
				cin >> c;
				if(c=='.') f[i1][i2]=0;
				else if(c=='B') f[i1][i2]=1;
				else if(c=='W') f[i1][i2]=2;
			}
		}

		for(i1=1;i1<=h;i1++){
			for(i2=1;i2<=w;i2++){
				if(f[i1][i2]==1) {
					f[i1][i2]=-1;
					dfs1(i2,i1);
				}
				else if(f[i1][i2]==2){
					f[i1][i2]=-1;
					dfs2(i2,i1);
				}
			}
		}

		count1=0;
		count2=0;
		for(i1=1;i1<=h;i1++){
			for(i2=1;i2<=w;i2++){
				if(f[i1][i2]==3) count1++;
				else if(f[i1][i2]==4) count2++;
			}
		}
		cout << count1 << " " << count2 << endl;
	}

	return 0;


}

void dfs1(int x,int y)
{
	int i1;
	int xx,yy;

	for(i1=0;i1<4;i1++){
		xx=x+dx[i1];
		yy=y+dy[i1];

		if(f[yy][xx]==0 || f[yy][xx]==4){
			f[yy][xx]+=3;
			dfs1(xx,yy);
		}
	}
}

void dfs2(int x,int y)
{
	int i1;
	int xx,yy;

	for(i1=0;i1<4;i1++){
		xx=x+dx[i1];
		yy=y+dy[i1];

		if(f[yy][xx]==0 || f[yy][xx]==3){
			f[yy][xx]+=4;
			dfs2(xx,yy);
		}
	}
}