#include <bits/stdc++.h>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define SORT(v) sort(ALL(v))
//#define scanf scanf_s
typedef pair<int, int> P;

int n, m;
string s;
int a[100005];
int b[100005];
int c[10005];
set<int> used;

char sima[55][55];
int cntw, cntb, cnttmp;
char tmp;
int di[] = { -1, 0, 0, 1 }; int dj[] = { 0, -1, 1, 0 };
int h, w;
void search(int i,int j)
{
	if (i < 0 || i >= h || j < 0 || j >= w) return;
	if (sima[i][j] == 'W')
	{
		if (tmp == 'B')
		{
			cnttmp = -10000000;
		}
		else tmp = 'W';
	}
	if (sima[i][j] == 'B')
	{
		if (tmp == 'W')
		{
			cnttmp = -10000000;
		}
		else tmp = 'B';
	}
	if (sima[i][j] == '.')
	{
		sima[i][j] = '@';
		cnttmp++;
		REP(k, 4) search(i + di[k], j + dj[k]);
	}
}

int main()
{
	while (cin >> w >> h, w)
	{
		REP(i, h)REP(j, w) cin >> sima[i][j];
		cntw = 0, cntb = 0;
		REP(i, h)REP(j, w)
		{
			cnttmp = 0;
			tmp = '@';
			if (sima[i][j] == '.')
			{
				search(i, j);
				if (cnttmp>0&&tmp == 'B') cntb += cnttmp;
				if (cnttmp>0&&tmp == 'W') cntw += cnttmp;
			}
		}
		cout << cntb << " " << cntw << endl;
	}
	return 0;
}