#include <bits/stdc++.h>

using namespace std;

int w, h;
char area[55][55];
int whose[55][55];
bool visited[2][55][55];

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

void dfs(int x, int y, int c)
{
  visited[c][y][x] = true;
  if(area[y][x] == '.'){
    if(c == 0) whose[y][x]++;
    else if(c == 1) whose[y][x]--;
  }
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i], ny = y + dy[i];
    if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
    if(area[ny][nx] == 'B' || area[ny][nx] == 'W') continue;
    if(visited[c][ny][nx]) continue;
    dfs(nx, ny, c);
  }
  return;
}

int main()
{
  while(cin >> w >> h, w || h){
    memset(area, '\0', sizeof(area));
    memset(whose, 0, sizeof(whose));
    memset(visited, false, sizeof(visited));
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++) cin >> area[i][j];
    }    
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
	if(area[i][j] == 'B') dfs(j, i, 0);
	else if(area[i][j] == 'W') dfs(j, i, 1);
      }
    }
    int bc = 0, wc = 0;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
	//printf("%2d", whose[i][j]);
	if(whose[i][j] == 1) bc++;
	else if(whose[i][j] == -1) wc++;
      }
      //cout << endl;
    }
    cout << bc << " " << wc << endl;
  }
  return 0;
}