#include "iostream"
#include "random"
#include "ctime"
#include "chrono"
#include "string"
#include "bitset"
#include "algorithm"
#include "map"
#include "queue"

using namespace std;


int main() {
	int H, W;
	cin >> W >> H;
	while (H) {
		vector<string>s(H);
		for (int i = 0; i < H; i++) {
			cin >> s[i];
		}
		int wh = 0;
		int bl = 0;
		int dir[] = { 1,0,-1,0,1 };
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (s[i][j] != '.') {
					continue;
				}
				bool w = false;
				bool b = false;
				queue<pair<int, int>>Q;
				Q.push({ i,j });
				vector<vector<bool>>flag(H, vector<bool>(W, true));
				flag[i][j] = false;
				while (!Q.empty()) {
					int cy = Q.front().first;
					int cx = Q.front().second;
					Q.pop();
					for (int k = 0; k < 4; k++) {
						int ny = cy + dir[k];
						int nx = cx + dir[k + 1];
						if (ny < 0 || nx < 0 || ny >= H || nx >= W) {
							continue;
						}
						if (!flag[ny][nx]) {
							continue;
						}
						if (s[ny][nx] == 'W') {
							flag[ny][nx] = false;
							w = true;
						}
						else if (s[ny][nx] == 'B') {
							flag[ny][nx] = false;
							b = true;
						}
						else {
							flag[ny][nx] = false;
							Q.push({ ny,nx });
						}
					}
				}
				if (w&&!b) {
					wh++;
					s[i][j] = 'W';
				}
				if (b&&!w) {
					bl++;
					s[i][j] = 'B';
				}
			}
		}
		cout << bl << " " << wh << endl;
		cin >> W >> H;
	}
	return 0;
}
