#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int w, h;
int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };
bool cnt[2][51][51];
char s[51][51];
char dir[]{ 'B','W' };

void dfs(int x, int y, int idx) {
	rep(i, 4) {
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx&&nx < h && 0 <= ny&&ny < w&&s[nx][ny] == '.' && !cnt[idx][nx][ny]) {
			cnt[idx][nx][ny] = true;
			dfs(nx, ny, idx);
		}
	}
}
int main() {
	while (scanf("%d%d", &w, &h), w) {
		memset(cnt, 0, sizeof(cnt));
		rep(i, h)scanf("%s", s[i]);
		rep(t, 2)rep(i, h)rep(j, w) {
			if (s[i][j] == dir[t])dfs(i, j, t);
		}
		int cb = 0, cw = 0;
		rep(i, h)rep(j, w) {
			if (cnt[0][i][j] && cnt[1][i][j])continue;
			if (cnt[0][i][j])cb++;
			if (cnt[1][i][j])cw++;
		}
		printf("%d %d\n", cb, cw);
	}
}