#ifndef _WIN32
#include<iostream>
#endif
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
typedef vector<string> VS;
VS wrap(VS v,char c) {
	int R = v.size(), C = v[0].size();
	VS ret(R + 2, string(C + 2, c));
	REP(i, R)REP(j, C)ret[i + 1][j + 1] = v[i][j];
	return ret;
}
const int dr[] = { 0,0,1,-1 };
const int dc[] = { 1,-1,0,0 };

void w(int r, int c,VS&x) {
	if (x[r][c] != '.')return;
	x[r][c] = 'w';
	REP(i, 4) {
		w(r + dr[i], c + dc[i], x);
	}
}
void b(int r, int c, VS&x) {
	if (x[r][c] != '.')return;
	x[r][c] = 'b';
	REP(i, 4) {
		b(r + dr[i], c + dc[i], x);
	}
}

int main() {
	int R, C;
	while (cin >> C >> R, R + C) {
		VS in(R);
		REP(i, R)cin >> in[i];
		in = wrap(in, '#');
		auto ww = in;
		auto bb = in;
		REP(i, R + 2)REP(j, C + 2)if (in[i][j] == 'W') {
			REP(k,4)w(i+dr[k], j+dc[k], ww);
		}
		REP(i, R + 2)REP(j, C + 2)if (in[i][j] == 'B') {
			REP(k,4)b(i+dr[k], j+dc[k], bb);
		}
		int wwww = 0, bbbb = 0;
		REP(i, R + 2)REP(j, C + 2)if (in[i][j] == '.') {
			if (ww[i][j] == 'w'&&bb[i][j] != 'b')wwww++;
			if (bb[i][j] == 'b'&&ww[i][j] != 'w')bbbb++;

		}
		cout << bbbb << " " << wwww << endl;
	}
}