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

string s[51];
bool done[51][51];

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

int main() {
	int w,h;
	while(1) {
		cin >> w >> h;
		memset(done, 0, sizeof(done));
		if(w==0 and h==0) break;
		for(int i=0;i<h;i++) {
			cin >> s[i];
		}
		int bcnt = 0, wcnt = 0;
		for(int y=0;y<h;y++) {
			for(int x=0;x<w;x++) {
				if(done[y][x] || s[y][x]=='W' || s[y][x]=='B') continue;
				bool bwith = false, wwith = false;
				queue<pair<int,int> > que;
				que.push({y,x});
				done[y][x] = true;
				int cnt = 1;
				while(!que.empty()) {
					auto tmp = que.front();
					que.pop();
					for(int k=0;k<4;k++) {
						int ny = tmp.first + dy[k];
						int nx = tmp.second + dx[k];
						if(0<=nx && nx<w && 0<=ny && ny<h) {
							if(s[ny][nx]=='.' && !done[ny][nx]) {
								done[ny][nx] = true;
								cnt++;
								que.push({ny,nx});
							} else if(s[ny][nx]=='W') {
								wwith = true;
							}else if(s[ny][nx]=='B') {
								bwith = true;
							}
						}
					}
				}
				if(bwith && !wwith) bcnt += cnt;
				if(!bwith && wwith) wcnt += cnt;
			}
		}
		cout << bcnt << " " << wcnt << endl;
	}
}
