#include<iostream>
using namespace std;

int H,W,sum;
char BW[50][50];

int judgeW(int h,int w)
{
  int a=0,b=0,c=0,d=0;
  if(h<0 || h>=H || w<0 || w>=W || BW[h][w]=='B' ||BW[h][w]=='0')return 0;
  if(BW[h][w]=='W')return 1;
  if(BW[h][w]=='.'){
    BW[h][w]='0';
    sum++;
  }
  a=judgeW(h+1,w);
  b=judgeW(h,w+1);
  c=judgeW(h-1,w);
  d=judgeW(h,w-1);
  return (a+b+c+d);
}
int judgeB(int h,int w)
{
  int a=0,b=0,c=0,d=0;
  if(h<0 || h>=H || w<0 || w>=W || BW[h][w]=='W' ||BW[h][w]=='1')return 0;
  if(BW[h][w]=='B')return 1;
  if(BW[h][w]=='0')BW[h][w]='1';
  a=judgeB(h+1,w);
  b=judgeB(h,w+1);
  c=judgeB(h-1,w);
  d=judgeB(h,w-1);
  return (a+b+c+d);
}

int main()
{
  int a,b,sumb,sumw;
  while(1){
    cin>>W>>H;
    if(H==0&&W==0)break;
    sumb=0;sumw=0;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin>>BW[i][j];
      }
    }
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
     	if(BW[i][j]=='.'){
	  sum=0;
	  a=judgeW(i,j);
          b=judgeB(i,j);
	  if((a!=0 && b!=0)||(a==0&&b==0))continue;
          else if(a>0)sumw+=sum;
	  else sumb+=sum;
	  }
      }
    }
    cout<<sumb<<" "<<sumw<<endl;
  }
  return 0;
}