#include<iostream>
#include<string>
using namespace std;

int w,h;
string s[100];

void solve(int i,int j,char c){

  if(i < 0 || j < 0 || i == w || j == h) return;
  if(s[j][i] == 'W' || s[j][i] == 'B') return;
  if(c == 'W' && s[j][i] == '*') return;
  if(c == 'B' && s[j][i] == '#') return;
  if(s[j][i] == '@') return;

  if(s[j][i] == '.' && c == 'W') s[j][i] = '*';
  if(s[j][i] == '.' && c == 'B') s[j][i] = '#';

  if(s[j][i] == '*' && c == 'B') s[j][i] = '@';
  if(s[j][i] == '#' && c == 'W') s[j][i] = '@';

  solve(i+1,j,c);
  solve(i,j+1,c);
  solve(i-1,j,c);
  solve(i,j-1,c);

}

int main(){

  while(true){
    cin >> w >> h;
    if(!w && !h) break;

    for(int i=0;i<h;i++) cin >> s[i];

    for(int i=0;i<w;i++){
      for(int j=0;j<h;j++){
	if(s[j][i] == 'W' || s[j][i] == 'B'){
	  solve(i+1,j,s[j][i]);
	  solve(i,j+1,s[j][i]);
	  solve(i-1,j,s[j][i]);
	  solve(i,j-1,s[j][i]);
	}
      }
    }

    int answ = 0,ansb = 0;

    for(int i=0;i<w;i++){
      for(int j=0;j<h;j++){
	if(s[j][i] == '*') answ++;
	if(s[j][i] == '#') ansb++;
      }
    }

    cout << ansb << " " << answ << endl;

  }
}