#include<iostream>
using namespace std;

int W,H;
char table[60][60] ;
char d[] = { '+' , '-' };
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};

void search( int x ,int y ,int c ){
	
	if( table[y][x] == 'W' || table[y][x] == 'B' ) return ;
	if( table[y][x] == '*' || table[y][x] == d[c]) return ;
	
	if( table[y][x] == d[(c+1)%2] ){
		table[y][x] = '*' ;
	}else {
		table[y][x] = d[c] ;
	}
	
	for( int k=0 ; k<4 ; k++ ){
		search( x+dx[k] , y+dy[k] , c );
	}
}

int main(){
	
	while( cin >> W >> H ){
		if( !W && !H ) break ;
		
		for( int i=0 ; i<=H+1 ; i++ ){
			for( int j=0 ; j<=W+1 ; j++ ){
				if( !i || !j || i==H+1 || j==W+1 ) table[i][j] = '*' ;
				else cin >> table[i][j] ;
			}
		}
		
		for( int i=1 ; i<=H ; i++ ){
			for( int j=1 ; j<=W ; j++ ){
				if( table[i][j] == 'W' || table[i][j] == 'B' ){
					for( int k=0 ; k<4 ; k++ ){
						search( j+dx[k] , i+dy[k] , (table[i][j]=='W')?0:1 );
					}
				}
			}
		}
		
		int ansW=0,ansB=0;
		for( int i=1 ; i<=H ; i++ ){
			for( int j=1 ; j<=W ; j++ ){
				if( table[i][j] == '+' ) ansW++;
				if( table[i][j] == '-' ) ansB++;
			}
		}
		
		cout << ansB << " " ;
		cout << ansW << endl;
	}
	
	return 0;
}