#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int h,w;
char grid[51][51];
bool iswhite[51][51];
bool isblack[51][51];
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};

int dfs(int px, int py,char c){
	int res = 1;
	REP(i,4){
		int nx = px + dx[i]; 
		int ny = py + dy[i];
		if(nx < 0 || ny <0 || nx > h-1 || ny > w-1) continue;
		if(grid[nx][ny] == c) return true;
		else return dfs(nx,ny);
	}
	return false;
}
int main(){
	while(1){
		cin >> w >> h;
		if(w==0&&h==0) break;
		REP(i,h) REP(j,w) cin >> grid[i][j];
		REP(i,h) REP(j,w) iswhite[i][j] = dfs(i,j,'W');
		REP(i,h) REP(j,w) isblack[i][j] = dfs(i,j,'B');
		int white = 0; int black = 0;
		REP(i,h) REP(j,w){
			if(iswhite[i][j] == true && isblack[i][j] == false) white++;
			else is(iswhite[i][j] == false && isblack[i][j] == true) black++;
		}
		cout << white << " " << black << endl;
	}
}