#include <bits/stdc++.h>

using namespace std;

#define rep(i, a) for (int (i) = 0; (i) < (a); (i)++)
#define reps(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define MP(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define all(v) (v).begin(), (v).end()

int minit[50][50];
int m[50][50];
int w, h;
const int W = 1;
const int B = 2;

void reset()
{
	rep(i, 50) rep(j, 50) {
		minit[i][j] = 0;
		m[i][j] = 0;
	}
}

void saiki(int r, int c, int x)
{
	if (!(r < h && r >= 0 && c < w && c >= 0)) return;
	if (minit[r][c] != 0 || (m[r][c] & x) != 0) return;
	m[r][c] += x;
	int dr[] = {-1,  0, 0, 1};
	int dc[] = { 0, -1, 1, 0};
	rep(i, 4) saiki(r+dr[i], c+dc[i], x);
}


int main()
{
	cin >> w >> h;
	while (w) {
		rep(i, h) rep(j, w) {
			char c;
			cin >> c;
			if (c == 'W') minit[i][j] = W;
			if (c == 'B') minit[i][j] = B;
			if (c == '.') minit[i][j] = 0;
		}
		rep(i, h) rep(j, w) {
			if (minit[i][j]) {
				int dr[] = {-1,  0, 0, 1};
				int dc[] = { 0, -1, 1, 0};
				rep (k, 4) saiki(i+dr[k], j+dc[k], minit[i][j]);
			}
		}
		int wn = 0, bn = 0;
		rep(i, h) rep(j, w) {
			if (m[i][j] == W) wn++;
			if (m[i][j] == B) bn++;
		}
		cout << bn << " " << wn << endl;
		cin >> w >> h;
		reset();
	}
}
