#include<iostream>
#include<cstring>

using namespace std;

const int MAX = 51;
const int BLACK = 100;
const int WHITE = 200;
int cnt[MAX][MAX],w,h;
char map[MAX][MAX];
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

void init(){
  memset(cnt,0,sizeof(cnt));
}

bool inside(int x, int y){
  return 0<=x&&x<w&&0<=y&&y<h;
}
void solve(int y,int x, int c){

  if(cnt[y][x] == BLACK+WHITE) return;
  if(c == BLACK && cnt[y][x] == BLACK) return;
  if(c == WHITE && cnt[y][x] == WHITE) return;

  cnt[y][x]+=c;

  for(int i = 0; i < 4; i++){
    int nx = x+dx[i];
    int ny = y+dy[i];
    if(inside(nx,ny)){
      if(map[ny][nx] == '.')solve(ny,nx,c);
    }
  }
}

int main(){

  while(cin >> w >> h && w+h){

    init();
    for(int i = 0; i < h; i++)
      for(int j = 0; j < w; j++)
	cin >> map[i][j];

    for(int i = 0; i < h; i++)
      for(int j = 0; j < w; j++){
	if(map[i][j] == 'W') solve(i,j,WHITE);
	if(map[i][j] == 'B') solve(i,j,BLACK);
      }
    int bb = 0,ww = 0;

    for(int i = 0; i < h; i++)
      for(int j = 0; j < w; j++){
	if(map[i][j] == '.' && cnt[i][j] == BLACK) bb++;
	if(map[i][j] == '.' && cnt[i][j] == WHITE) ww++;
      }

    cout << bb << " " << ww << endl;
  }
  
  return 0;
}