#include <string.h>
#include <iostream>
#include <queue>
#include <complex>
#include <functional>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

typedef complex<double> P;
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define EQV(a,b) ( EQ( a.real(), b.real() ) && EQ( a.imag(), b.imag() ) )

#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,n) for(int i=a;i<=n;i++)

//---------------------------------------------------------------------
vector<string> f(10);

int DX[] = { 1,0,-1,0 };
int DY[] = { 0,1,0,-1 };
int w, h;

void rec(int x, int y, char c) {
	rep(i, 4) {
		int nx = x + DX[i]; int ny = y + DY[i];
		if (nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
		
		if (f[ny][nx] == '.') {
			f[ny][nx] = (c == 'B' ? 'b' : 'w');
			rec(nx, ny, c);
		}
		else if ((f[ny][nx] == 'b' && c == 'W') || (f[ny][nx] == 'w' && c == 'B')) {;
			f[ny][nx] = 'o';
			rec(nx, ny, c);
		}
	}
}

int main() {
	while (cin >> w >> h, (w || h)) {
		f.clear();
		rep(y, h) {
			string s;
			cin >> s;
			f.push_back(s);
		}
		rep(y, h) {
			rep(x, w) {
				if (f[y][x] == 'W' || f[y][x] == 'B') rec(x, y,  f[y][x]);
			}
		}
		int blacks = 0, whites = 0;
		rep(y, h) {
			rep(x, w) {
				if (f[y][x] == 'b') blacks++;
				else if (f[y][x] == 'w') whites++;
			}
		}
		cout << blacks << " " << whites << endl;
	}
	return 0;
}