#include<iostream>
#include<climits>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<list>
#include<string>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF INT_MAX/3

char MAP[50][50];
int B_area = 0;
int W_area = 0;
int W, H;
int temp = 0;
//0:black,1:white
int color = -1;
int color_f = 1;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };


void dfs(int x, int y) 
{
	if (x < 0 || W <= x || y < 0 || H <= y)return;
	if (MAP[y][x]=='D')return;
	else if (MAP[y][x] == '.')
	{
		temp++;
		MAP[y][x] = 'D';
		for (int r = 0; r < 4; r++)
		{
			int nx = x + dx[r];
			int ny = y + dy[r];
			dfs(nx, ny);
		}
	}
	else if (MAP[y][x] == 'W')
	{
		if(color==-1)color = 1;
		else if (color == 0)color_f = -1;
	}
	else if (MAP[y][x] == 'B')
	{
		if (color == -1)color = 0;
		else if (color == 1)color_f = -1;
	}
	
	if (color_f == -1)
	{
		W_area = 0;
		B_area = 0;
	}
	else if (color == 0)
	{
		B_area = temp;
		W_area = 0;
	}
	else if (color == 1)
	{
		W_area = temp;
		B_area = 0;
	}
}

int main()
{
	while (1)
	{
		B_area = 0;
		W_area = 0;
		cin >> W >> H;
		if (W == 0)break;
		int ansB=0, ansW=0;
		REP(i, H)REP(j, W)cin >> MAP[i][j];
		REP(i, H)REP(j, W)
		{
			if (MAP[i][j] == '.')
			{
				color = -1;
				color_f = 1;
				temp = 0;
				W_area = 0;
				B_area = 0;
				dfs(j, i);
				ansB += B_area;
				ansW += W_area;
			}
		}
		cout << ansB << " " << ansW << endl;
	}
	return 0;
}