#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;
const double EPS = 1e-10;

int w, h;
char field[60][60];
int color[60][60];
void dfs(int y, int x, int col)
{
	const int dy[] = {-1, 0, 1, 0};
	const int dx[] = {0, -1, 0, 1};
	
	rep(i, 4){
		int py = y + dy[i];
		int px = x + dx[i];
		if(py<0 || h<=py || px<0 || w<=px)
			continue;
		if(color[py][px] & col)
			continue;
		if(field[py][px] != '.')
			continue;
		
		color[py][px] |= col;
		dfs(py, px, col);
	}
}

int main()
{
	while(scanf("%d%d", &w, &h), w){
		rep(i, h) rep(j, w)
			color[i][j] = 0;
		
		rep(i, h)
			scanf("%s", field[i]);
		
		rep(i, h) rep(j, w){
			if(field[i][j] != '.'){
				dfs(i, j, field[i][j]=='W' ? 1 : 2);
			}
		}
		
		int a=0, b=0;
		rep(i, h) rep(j, w){
			a += color[i][j] == 1;
			b += color[i][j] == 2;
		}
		printf("%d %d\n", b, a);
	}
	
	return 0;
}