#include <cstdio>
#include <cstring>
using namespace std;

char a[52][52];
bool visit[52][52];
int u, cnt;

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

void dfs(int y, int x){
	++cnt;

	for(int i = 0; i < 4; ++i){
		int ny = y + dy[i], nx = x + dx[i];
		switch( a[ny][nx] ){
			case '.':
				if( !visit[ny][nx] ){
					visit[ny][nx] = true;
					dfs(ny, nx);
				}
				break;
			case 'B':
				u |= 1;
				break;
			case 'W':
				u |= 2;
				break;
		}
	}
}

int main(){
	int w, h;
	while(scanf("%d%d", &w, &h), w != 0){
		int ans[4] = {};

		memset(a, 0, sizeof a);
		memset(visit, 0, sizeof visit);

		for(int i = 1; i <= h; ++i){
			scanf(" %s", a[i] + 1);
		}

		for(int i = 1; i <= h; ++i)
		for(int j = 1; j <= w; ++j){
			if( !visit[i][j] && a[i][j] == '.' ){
				visit[i][j] = true;
				u = cnt = 0;
				dfs(i, j);
				ans[u] += cnt;
			}
		}
		
		printf("%d %d\n", ans[1], ans[2]);
	}
}