#include <bits/stdc++.h>

using namespace std;

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

void dfs(vector<vector<int> >& canGo, int i, int j){
  canGo[i][j] = 3;
  counter++;

  for(int k = 0; k < 4; k++){
    if(canGo[i + dx[k]][j + dy[k]] == 0) dfs(canGo, i + dx[k], j + dy[k]);
    if(canGo[i + dx[k]][j + dy[k]] == 1){
      if(borw == 0 || borw == 1)  borw = 1;
      else borw = 3;
    }

    if(canGo[i + dx[k]][j + dy[k]] == 2){
      if(borw == 0 || borw == 2)  borw = 2;
      else borw = 3;
    }
  }
}


int main(void)
{
  int w, h;
  while(1){
    cin >> w >> h; if(w == 0 && h == 0) break;

    int B = 0, W = 0;
    vector<vector<int> > canGo(h + 2, vector<int>(w + 2, 3));

    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= w; j++){
	char input; cin >> input;
	if(input == '.') canGo[i][j] = 0;
	if(input == 'B') canGo[i][j] = 1;
	if(input == 'W') canGo[i][j] = 2;
      }
    }
   
    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= w; j++){
	borw = 0;
	counter = 0;
       if(canGo[i][j] == 0){
	  dfs(canGo, i, j);
	  if(borw == 1) B += counter;
	  if(borw == 2) W += counter;
        }
      }
    }

    cout << B << " " << W << endl;

  }
  return 0;
  
}