#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

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

int w,h;
vector<string> board;

bool input(){
	cin>>w>>h;
	if(w==0)return false;
	
	board.clear();
	rep(i,h){
		string s;
		cin>>s;
		board.pb(s);
	}
	return true;
}

int B,W;

int saiki(int y,int x){
	if(y<0 || y>=h || x<0 || x>=w)return 0;
	
	if(board[y][x]=='#')return 0;
	
	if(board[y][x]=='W'){
		W++;
		return 0;
	}
	if(board[y][x]=='B'){
		B++;
		return 0;
	}
	
	int ret = 1;
	int dx[] = {1,0,-1,0};
	int dy[] = {0,1,0,-1};
	
	board[y][x]='#';
	
	rep(i,4){
		ret += saiki(y+dy[i], x+dx[i]);
	}
	
	return ret;
}

void solve(){
	int ansB = 0;
	int ansW = 0;
	rep(i,h){
		rep(j,w){
			B=0;
			W=0;
			
			int cnt = saiki(i,j);
			
			if(W==0 && B!=0)ansB += cnt;
			if(B==0 && W!=0)ansW += cnt;
		}
	}
	
	cout<<ansB<<" "<<ansW<<endl;
}

int main(){
	while(input())solve();
}