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

vector<vector<int>>field;
vector<vector<bool>>used;


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

pair<int, int>getans(const int y, const int x) {
	if (used[y][x]) {
		return make_pair(field[y][x]?field[y][x]:3, 0);
	}
	used[y][x] = true;
	if (field[y][x]) {
		return make_pair(field[y][x], 0);
	}
	int nowcolor = 3;
	int nowcount = 1;
	for (int i = 0; i < 4; ++i) {
		pair<int, int>p(getans(y + dy[i], x + dx[i]));
		nowcolor &= p.first;
		nowcount += p.second;
		
	}
	return make_pair(nowcolor, nowcount);
}

int main() {
	while (1) {
		int w, h; cin >> w >> h;
		field.clear();
		used.clear();
		field.resize(h + 2);
		used.resize(h + 2);
		for (int i = 0; i < h + 2; ++i) {
			used[i].resize(w + 2);
		}
		for (int i = 0; i < w + 2; ++i) {
			field[0].push_back(3);
		}
		if (!w)break;
		for (int i = 0; i < h; ++i) {
			field[i + 1].push_back(3);
			string st; cin >> st;
			for (int j = 0; j < w; ++j) {
				if (st[j] == '.') {
					field[i + 1].push_back(0);
				}
				else if (st[j] == 'W') {
					field[i + 1].push_back(1);
				}
				else {
					field[i + 1].push_back(2);
				}
			}
			field[i + 1].push_back(3);
		}
		for (int i = 0; i < w + 2; ++i) {
			field[h+1].push_back(3);
		}
		int whnum = 0;
		int blnum = 0;
		for (int y = 0; y < h + 2; ++y) {
			for (int x = 0; x < w + 2; ++x) {
				if (!used[y][x]) {
					pair<int, int>a(getans(y, x));
					if (a.first == 1)whnum+=a.second;
					if (a.first == 2)blnum+= a.second;

				}
			}
		}
		cout << blnum << " " <<whnum << endl;
	}
	return 0;
}