#include <string>
#include <vector>
#include <iostream>

using namespace std;

int W, H; vector<string> M;

const vector<int> dx = { 0, 1, 0, -1 };
const vector<int> dy = { -1, 0, 1, 0 };

vector<vector<bool> > ok;

void rec(int x, int y)
{
	ok[y][x] = true;

	if (M[y][x] != '.')
	{
		return;
	}

	for (int dir = 0; dir < 4; dir++)
	{
		int tx = x + dx[dir];
		int ty = y + dy[dir];

		if (0 <= tx && tx < W && 0 <= ty && ty < H && ok[ty][tx] == false)
		{
			rec(tx, ty);
		}
	}
}

int main()
{
	while (true)
	{
		cin >> W >> H;

		if (W == 0 && H == 0) { break; }

		M = vector<string>(H);

		for (int i = 0; i < H; i++)
		{
			cin >> M[i];
		}

		int b = 0, w = 0;

		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (M[i][j] == '.')
				{
					ok = vector<vector<bool> >(H, vector<bool>(W, false));

					rec(j, i);

					int br = 0, wr = 0;

					for (int k = 0; k < H; k++)
					{
						for (int l = 0; l < W; l++)
						{
							if (M[k][l] == 'W' && ok[k][l] == true)
							{
								wr++;
							}

							if (M[k][l] == 'B' && ok[k][l] == true)
							{
								br++;
							}
						}
					}

					if (wr != 0 && br == 0) { w++; }
					if (br != 0 && wr == 0) { b++; }
				}
			}
		}

		cout << b << ' ' << w << endl;
	}

	return 0;
}