#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int h,w,c[55][55],dy[]={0,1,0,-1},dx[]={1,0,-1,0};
char m[55][55];

void dfs(int y,int x,int C){
	if((c[y][x]|C)==c[y][x])return;
	c[y][x]|=C;
	rep(i,4){
		int ny=y+dy[i],nx=x+dx[i];
		if(0<=ny&&ny<h&&0<=nx&&nx<w&&m[ny][nx]=='.')dfs(ny,nx,C);
	}
}

int main(){
	while(cin>>w>>h,w){
		int B=0,W=0;
		memset(c,0,sizeof(c));
		rep(i,h)cin>>m[i];
		rep(i,h)rep(j,w){
			if(m[i][j]=='B')dfs(i,j,1);
			if(m[i][j]=='W')dfs(i,j,2);
		}
		rep(i,h)rep(j,w)if(m[i][j]=='.'){
			if(c[i][j]==1)B++;
			if(c[i][j]==2)W++;
		}
		cout<<B<<" "<<W<<endl;
	}
}