#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> P;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int w, h;
bool visited[64][64];
vector<string> maze;

bool check(int x, int y){
	return x >= 0 && x < w && y >= 0 && y < h;	
}

int dfs(int x, int y){
	if(maze[y][x] == 'B')
		return 1;
	else if(maze[y][x] == 'W')
		return 2;
	
	int res = 0;
	for(int i = 0; i < 4; ++i){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(!check(nx, ny) || visited[ny][nx])
			continue;
		visited[ny][nx] = true;
		res |= dfs(nx, ny);
	}
	return res;
}
int main() {
	while(cin >> w >> h && (w || h)){
		string a;
		maze.clear();
		int cntB = 0, cntW = 0;
		for(int i = 0; i < h; ++i){
			cin >> a;
			maze.push_back(a);
		}
		for(int y = 0; y < h; ++y){
			for(int x = 0; x < w; ++x){
				if(maze[y][x] != '.')
					continue;
				memset(visited, 0, sizeof(visited));
				visited[y][x] = true;
				int res = dfs(x, y);
				if(res == 1)
					cntB++;
				else if(res == 2)
					cntW++;
			}
		}
		cout << cntB << " " << cntW << endl;
	}
	return 0;
}