#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;

int w, h;

string field[100];

bool check[100][100];

string search(int y, int x){
	if(y < 0 || x < 0 || y >= h || x >= w){
		return "";
	}
	if(check[y][x]){
		return "";
	}
	if(field[y][x] != '.'){
		string ret = " ";
		ret[0] = field[y][x];
		return ret;
	}
	check[y][x] = true;
	
	return search(y - 1, x) + search(y + 1, x) + search(y, x - 1) + search(y, x + 1) + "1";
}

int main(){
	
	while(true){
		
		cin >> w >> h;
		if(w == 0 && h == 0){
			break;
		}
		
		for(int i = 0; i < h; i++){
			cin >> field[i];
		}
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				check[i][j] = false;
			}
		}
		
		int ans_b = 0;
		int ans_w = 0;
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				string ret = search(i, j);
				bool flag1 = false;
				bool flag2 = false;
				int count = 0;
				for(int k = 0; k < ret.size(); k++){
					if(ret[k] == 'B'){
						flag1 = true;
					}else if(ret[k] == 'W'){
						flag2 = true;
					}else{
						count++;
					}
				}
				if(flag1 && flag2){
					continue;
				}else if(flag1){
					ans_b += count;
				}else if(flag2){
					ans_w += count;
				}
			}
		}
		
		cout << ans_b << " " << ans_w << endl;
	}
	
	return 0;
}