#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef pair <int,int> pii;
#define FST first
#define SEC second

int w,h;
int dd[8]={0,1,0,-1,0};

void bfs(char map[50][50]){
  stack <pii> q;
  int bc=0,wc=0;
  rep(i,h){
    rep(j,w){
      if(map[j][i]=='.'){
	q.push(pii(j,i));
	int count=0;
	pii state=pii(0,0);
	while(!q.empty()){
	  int cx=q.top().FST,cy=q.top().SEC;
	  q.pop();
	  if(map[cx][cy]=='.')
	    count++;
	  map[cx][cy]='#';
	  rep(r,4){
	    int nx=cx+dd[r],ny=cy+dd[r+1];
	    if(nx<0 || ny<0 || nx>=w || ny>=h || map[nx][ny]=='#')
	      continue;
	    if(map[nx][ny]=='B'){
	      state.FST=1;
	      continue;
	    }
	    if(map[nx][ny]=='W'){
	      state.SEC=1;
	      continue;
	    }
	    q.push(pii(nx,ny));
	  }
	}
	if(state==pii(1,0))
	  bc+=count;
	if(state==pii(0,1))
	  wc+=count;
      } 
    }
  }
  printf("%d %d\n",bc,wc);
}

int main(){
  for(;;){
    cin >> w >> h;
    if(!(w+h)) break;
    char map[50][50];
    rep(i,h){
      rep(j,w){
        cin >> map[j][i];
      }
    }
    bfs(map);
  }
  return 0;
}