#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>
#include<stack>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))

const char dx[]={0,1,0,-1},dy[]={1,0,-1,0};

int w,h;
char a[51][51],b[51][51];
	
void dfs(int x,int y,char c){
	rep(i,4)if(x+dx[i]>=0&&x+dx[i]<h&&y+dy[i]>=0&&y+dy[i]<w){
		if(a[x+dx[i]][y+dy[i]]=='.' && (b[x+dx[i]][y+dy[i]]&c)!=c){
			b[x+dx[i]][y+dy[i]]|=c;
			dfs(x+dx[i],y+dy[i],c);
		}
	}
}
int main(){
	do{
		scanf("%d%d",&w,&h);
		if(!w)break;
		rep(i,h)scanf("%s",a[i]);
		int bl=0,wi=0;
		memset(b,0,sizeof(b));
		rep(i,h)rep(j,w){
			if(a[i][j]!='.')dfs(i,j,a[i][j]=='B'?2:1);
		}
		rep(i,h)rep(j,w){
			bl+=b[i][j]==2;
			wi+=b[i][j]==1;
		}
		printf("%d %d\n",bl,wi,0);
	}while(1);
	return 0;
}