
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

typedef long long ll;
using namespace std;

int dx[] = {1, 0 ,-1, 0};
int dy[] = {0, 1, 0, -1};
bool dfs(char c, int i, int j, int h, int w, vector<vector<char> > &a){
	if(a[i][j] == c) return true;
	if(a[i][j] != '.') return false;
	a[i][j] = 'Z';
	
	bool res = false;
	for(int k=0;k<4;k++){
		int ny = i+dy[k], nx = j+dx[k];
		if(0 <= nx && nx < w && 0 <= ny && ny < h){
			if(a[ny][nx] != 'Z') res |= dfs(c, ny, nx, h, w, a);
		}
	}
	return res;
}

bool solve(){
	int w, h;
	cin>> w>> h;
	if(w==0 && h==0) return false;
	
	vector<vector<char> > in(h, vector<char>(w));
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>> in[i][j];
		}
	}
	
	int ansb = 0, answ = 0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(in[i][j] == '.'){
				vector<vector<char> > a;
				a = in;
				bool bb = dfs('B', i, j, h, w, a);
				a = in;
				bool ww = dfs('W', i, j, h, w, a);
				if(bb && !ww) ansb++;
				if(!bb && ww) answ++;
			}
		}
	}
	
	cout<< ansb<< " "<< answ<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);

	while(solve());

	return 0;
}

 