#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

string field[50];


int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int w, h;

int seedfill(int x, int y){
	queue<P> q;
	q.push(MP(x,y));
	set<char> s;
	int cnt = 0;

	while(!q.empty()){
		P p = q.front();
		q.pop();

		if(field[p.Y][p.X] != '.'){
			s.insert(field[p.Y][p.X]);
			continue;
		}
		field[p.Y][p.X] = '#';
		cnt++;

		rep(i, 4){
			int nx = p.X+dx[i];
			int ny = p.Y+dy[i];
			if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
			q.push(MP(nx, ny));
		}
	}
	bool white = (s.find('W') != s.end());
	bool black = (s.find('B') != s.end());
	if(white && black) return 0;
	if(black) return -cnt;
	if(white) return  cnt;
	return 0;
}

int main(){
	while(1){
		cin >> w >> h;
		if(!w && !h)break;
		rep(i, h){
			cin >> field[i];
		}
		int br = 0;
		int wh = 0;
		rep(i, h){
			rep(j, w){
				if(field[i][j] == '.'){
					int ret = seedfill(j, i);
					if(ret < 0) br += -ret;
					else wh += ret;
				}
			}
		}
		cout << br << ' ' << wh << endl;
	}

	return 0;
}