#include<iostream>
#include<cstring>
#define Black 1
#define White 2
#define Double 3
using namespace std;

char map[50][50];
int acs[50][50]={0};
int w,h;
int dxy[4][2]={{1,0},{0,1},{-1,0},{0,-1}};

void dfs(int y,int x,int type){
  if(0<=y && y<h && 0<=x && x<w){
    if(map[y][x]=='.' && (acs[y][x]&type)!=type){
      acs[y][x]+=type;
      for(int k=0;k<4;k++){
	dfs(y+dxy[k][1],x+dxy[k][0],type);
      }
    }
  }
}

int main(){
  while(cin>>w>>h,w){
    memset(map,'.',sizeof(map));
    memset(acs,0,sizeof(acs));
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>map[i][j];
	if(map[i][j]!='.') acs[i][j]=Double;
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(map[i][j]=='B'){
	  //	  acs[i][j]=Double;
	  for(int k=0;k<4;k++){
	    dfs(i+dxy[k][1],j+dxy[k][0],Black);
	  }
	}else if(map[i][j]=='W'){
	  //acs[i][j]=Double;
	  for(int k=0;k<4;k++){
	    dfs(i+dxy[k][1],j+dxy[k][0],White);
	  }
	}
      }
    }
    int black=0;
    int white=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(acs[i][j]==Black){
	  black++;
	}else if(acs[i][j]==White){
	  white++;
	}
      }
    }
    cout<<black<<" "<<white<<endl;
  }
  return 0;
}