#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<string.h>
#include<functional>
using namespace std;

#define INF 1<<21
#define DIV 1000000007

typedef pair<int, int>P;


int w, h;
int cnt;
char f[51][51];
int dx[] = { 1,-1,0,0 }, dy[] = { 0,0,1,-1 };

void rec(int x, int y, char c) {
  for (int i = 0; i < 4; i++) {
	int nx = x + dx[i];
	int ny = y + dy[i];
	if (nx <= 0 || w < nx || ny <= 0 || h < ny )continue;

	if (c == 'B') {
	  if (f[ny][nx] == 'w') {
		f[ny][nx] = 'u';
		rec(nx, ny, c);
	  }
	  else if (f[ny][nx] == '.') {
		f[ny][nx] = 'b';
		rec(nx, ny, c);
	  }
	}
	else if (c == 'W') {
	  if (f[ny][nx] == 'b') {
		f[ny][nx] = 'u';
		rec(nx, ny, c);
	  }
	  else if (f[ny][nx] == '.') {
		f[ny][nx] = 'w';
		rec(nx, ny, c);
	  }
	}
  }
}

int main() {
  while (cin >> w >> h, (w || h)) {
	memset(f, 0, sizeof(f));
	for (int y = 1; y <= h; y++) {
	  for (int x = 1; x <= w; x++) {
		cin >> f[y][x];
	  }
	}
	for (int y = 1; y <= h; y++) {
	  for (int x = 1; x <= w; x++) {
		if (f[y][x] == 'W' || f[y][x] == 'B') {
		  rec(x, y, f[y][x]);
		}
	  }
	}
	int blacks = 0, whites = 0;
	for (int y = 1; y <= h; y++) {
	  for (int x = 1; x <= w; x++) {
		if (f[y][x] == 'b') {
		  blacks++;
		}
		else if (f[y][x] == 'w') {
		  whites++;
		}
	  }
	}
	cout << blacks << " " << whites << endl;
  }
  return 0;
}