#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k,ll p) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int w, h;
char a[50][50];
bool c[50][50], d[50][50];
signed main() {
	while (cin >> w >> h&&w + h > 0) {
		int ans1 = 0, ans2 = 0;
		for (int i = 0; i < h; i++) {
			string s;
			cin >> s;
			for (int j = 0; j < w; j++) {
				a[i][j] = s[j];
				c[i][j] = 0;
				d[i][j] = 0;
			}
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (a[i][j] != 'B'&&a[i][j] != 'W'&&!c[i][j]) {
					queue<H>q;
					q.push(H{ i,j });
					bool B = 0, W = 0;
					while (!q.empty()) {
						H t = q.front(); q.pop();
						if (a[t.x][t.y] == 'B') {
							B = 1; continue;
						}
						if (a[t.x][t.y] == 'W') {
							W = 1; continue;
						}
						if (c[t.x][t.y]) continue;
						c[t.x][t.y] = 1;
						if (t.x > 0)
							q.push(H{ t.x - 1,t.y });
						if (t.x < h - 1)
							q.push(H{ t.x + 1,t.y });
						if (t.y > 0)
							q.push(H{ t.x,t.y - 1 });
						if (t.y < w - 1)
							q.push(H{ t.x,t.y + 1 });
					}
					if (B != W) {
						q.push(H{ i,j });
						while (!q.empty()) {
							H t = q.front(); q.pop();
							if (a[t.x][t.y] == 'B') {
								B = 1; continue;
							}
							if (a[t.x][t.y] == 'W') {
								W = 1; continue;
							}
							if (d[t.x][t.y]) continue;
							d[t.x][t.y] = 1;
							if (B) ans1++;
							else ans2++;
							if (t.x > 0)
								q.push(H{ t.x - 1,t.y });
							if (t.x < h - 1)
								q.push(H{ t.x + 1,t.y });
							if (t.y > 0)
								q.push(H{ t.x,t.y - 1 });
							if (t.y < w - 1)
								q.push(H{ t.x,t.y + 1 });
						}
					}
				}
			}
		}
		cout << ans1 << " " << ans2 << endl;
	}
	getchar(); getchar();
}


Measured memory_bytes: 3256