#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll w,h;
char s[99][99];
ll d4[]={0,-1,0,1,0};
void f(char c,int a[][99]){
	int que[10000],quecnt=0;
	rep(i,0,h)rep(j,0,w){
		if(s[i][j]==c){
			a[i][j]=10;
			que[quecnt++]=i*128+j;
		}else{
			a[i][j]=0;
		}
	}
	for(int idx=0;idx<quecnt;idx++){
		int x=que[idx]/128;
		int y=que[idx]%128;
		rep(k,0,4){
			int xx=x+d4[k];
			int yy=y+d4[k+1];
			if(0<=xx&&xx<h&&0<=yy&&yy<w&&!a[xx][yy]){
				if(s[xx][yy]=='.'){
					que[quecnt++]=xx*128+yy;
					a[xx][yy]=2;
				}else{
					a[xx][yy]=1;
				}
			}
		}
	}
}

int a[99][99];
int b[99][99];

int main(){
	while(scanf("%lld%lld",&w,&h),w){
		rep(i,0,h)scanf(" %s",s[i]);
		f('B',a);
		f('W',b);
		ll x=0,y=0;
		rep(i,0,h)rep(j,0,w){
			if(a[i][j]==2&&b[i][j]!=2)x++;
			if(a[i][j]!=2&&b[i][j]==2)y++;
		}
		printf("%lld %lld\n",x,y);
	}
}
