#include <iostream>
using namespace std;
int w,h,c1,c2,b,d;
char a[51][51];
int dfs(int i,int j){
  if(i==h||j==w||i<0||j<0||a[i][j]=='#')return 0;
  if(a[i][j]=='W'){d++;return 0;}
  else if(a[i][j]=='B'){b++;return 0;}
  int s=1;
  a[i][j]='#';
  s+=dfs(i+1,j);
  s+=dfs(i-1,j);
  s+=dfs(i,j+1);
  s+=dfs(i,j-1);
  return s;
}
int main(){
  int i,j,ans;
  while(cin>>w>>h,w&&h){
    c1=c2=0;
    for(i=0;i<h;i++)scanf("%c"&a[i]);
    for(i=0;i<h;i++)for(j=0;j<w;j++)if(a[i][j]=='.'){
      d=b=0;
      ans=dfs(i,j);
      if(b&&d)continue;
      else if(b>d)c1+=ans;
      else if(b<d)c2+=ans;
    }
    cout<<c1<<" "<<c2<<endl;
}}