#include<iostream>
#include<string>
#include<vector>
#define B 'B'
#define W 'W'
#define DOT '.'
#define NG '1'

using namespace std;

void Search1(vector<string>&, int, int, int, int, int&, char&);
void Search2(vector<string>&, int, int, int, int, int&, char&);

int main(){
  int i, j, w, h, count, black, white, k;
  char c;
  string s;
  vector<string> data;

  while(1){
    cin >> w >> h;
    if(w == 0 && h == 0) break;

    for(i=0; i<h; ++i){
      cin >> s;
      data.push_back(s);
    }
    for(i=0, black=0, white=0; i<h; ++i){
      for(j=0; j<w; ++j){
	if(data[i][j] == DOT){
	  count = 0;
	  c = DOT;
	  Search1(data, i, j, h, w, count, c);
	  if(c == B) black += count;
	  else if(c == W) white += count;
	}
      }
    }

    cout << black << " " << white << endl;
    data.clear();
  }
  return 0;
}

void Search1(vector<string>& data, int i, int j, int h, int w, int& count, char& c){
  data[i][j] = NG;
  ++count;
  Search2(data, i-1, j, h, w, count, c);
  Search2(data, i+1, j, h, w, count, c);
  Search2(data, i, j-1, h, w, count, c);
  Search2(data, i, j+1, h, w, count, c);
}

void Search2(vector<string>& data, int i, int j, int h, int w, int& count, char& c){
  if(i > -1 && i < h && j > -1 && j < w){
    if(data[i][j] == DOT){
      Search1(data, i, j, h, w, count, c);
    }else if(data[i][j] == B || data[i][j] == W){
      if(c == DOT) c = data[i][j];
      else if(c != data[i][j]) c = NG;
    }
  }
}