#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int di[] = {0, -1, 0, 1};
int dj[] = {-1, 0, 1, 0};

int main() {
	for (;;) {
		int w, h; cin >> w >> h;
		if (w == 0) break;
		vector<string> a(h);
		for (int i = 0; i < h; i++) cin >> a[i];
		vector< vector<bool> > b(h, vector<bool>(w)), c(h, vector<bool>(w));
		for (int t = 0; t < h * w; t++)
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++)
					if (a[i][j] == '.')
						for (int k = 0; k < 4; k++) {
							int _i = i + di[k], _j = j + dj[k];
							if (_i >= 0 && _i < h && _j >= 0 && _j < w) {
								if (a[_i][_j] == 'B' || b[_i][_j]) b[i][j] = true;
								if (a[_i][_j] == 'W' || c[_i][_j]) c[i][j] = true;
							}
						}
		int cnt1 = 0, cnt2 = 0;
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++) {
				if (b[i][j] && !c[i][j]) cnt1++;
				if (!b[i][j] && c[i][j]) cnt2++;
			}
		cout << cnt1 << ' ' << cnt2 << endl;
	}
}