#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int sx,sy;
int gx,gy;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int co;
vector<vector<char> >in;
bool h;
void func(char d,char q,int x,int y){
	in[x][y]=q;
	co++;
	rep(i,4){
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(in[nx][ny]=='.'){
			func(d,q,nx,ny);
		}else if(in[nx][ny]==d)h=false;
	}
}
int main(){
	int n,m;
	while(cin>>m>>n,m+n){
		vector<vector<char> >tmp(n+2,vector<char>(m+2));
		rep(i,n+2)rep(j,m+2){
			if(!i||!j||i==n+1||j==m+1)tmp[i][j]='!';
			else cin>>tmp[i][j];
		}
		//cout<<n<<" "<<m<<endl;
		in=tmp;
		int b=0,w=0;
		rep(i,n+2)rep(j,m+2){
			h=true;
			if(in[i][j]=='.'){
				rep(k,4){
					int nx=i+dx[k];
					int ny=j+dy[k];
					if(in[nx][ny]!='W'&&in[nx][ny]!='B')continue;
					co=0;
					if(in[nx][ny]=='W'){
						func('B','W',i,j);
						if(h)w+=co;
						break;
					}else{
						func('W','B',i,j);
						if(h)b+=co;
						break;
					}
				}
			}
		}
		cout<<b<<" "<<w<<endl;
		//rep(i,n+2){rep(j,m+2)cout<<in[i][j];cout<<endl;}
	}
}