#include<iostream>
#include<cstring>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int w,h;
string grid[55],col[55];
bool vis[55][55];
int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};

int count(char color){
  int res = 0;
  rep(i,h)rep(j,w)if(col[i][j]==color)res++;
  return res;
}

void rec(int y,int x,int color){
  if(vis[y][x])return;
  vis[y][x] = true;

  if(grid[y][x]=='.'){
    if(col[y][x] == '.' || col[y][x] == color)col[y][x] = color;
    else col[y][x] = 'G';
  }
    
  rep(d,4){
    int ny = y+dy[d], nx = x+dx[d];
    if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
    if(grid[ny][nx]!='.')continue;
    rec(ny,nx,color);
  }
}

int main(){
  while(cin >> w >> h, w){
    rep(i,h){
      cin >> grid[i];
      col[i] = "";
      rep(j,w)col[i] += '.';
    }
    
    rep(i,h){
      rep(j,w){
	if(grid[i][j]!='.'){
	  memset(vis,0,sizeof(vis));
	  rec(i,j,grid[i][j]);
	}
      }
    }
   
    cout << count('B') << " " << count('W') << endl;
  }
}