#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
int main(){
  int w, h;
  vector<int> v;
  vector<int> ex, ey;
  ex = {1,-1,0,0};
  ey = {0,0,1,-1};
  while (cin >> w >> h, w){
    vector<string> M(h);
    vector< vector<int> > F(h, vector<int>(w,9));
    queue< vector<int> > que_W, que_B;
    for (int i = 0; i < h; ++i){
      cin >> M[i];
      for (int j = 0; j < w; ++j){
	if (M[i][j] == 'W') que_W.push({i,j});
	else if (M[i][j] == 'B') que_B.push({i,j});
	else F[i][j] = 0;
      }
    }
   
    while(!que_W.empty()){
      int x = que_W.front()[0], y = que_W.front()[1];
      que_W.pop();
      for (int i = 0; i < 4; ++i){
	if (0 <= x+ex[i] && x+ex[i] < h && 0 <= y+ey[i] && y+ey[i] < w && !F[x+ex[i]][y+ey[i]]){
	  --F[x+ex[i]][y+ey[i]];
	  que_W.push({x+ex[i],y+ey[i]});
	}
      }
    }
    while(!que_B.empty()){
      int x = que_B.front()[0], y = que_B.front()[1];
      que_B.pop();
      for (int i = 0; i < 4; ++i){
	if (0 <= x+ex[i] && x+ex[i] < h && 0 <= y+ey[i] && y+ey[i] < w && M[x+ex[i]][y+ey[i]] == '.'){
	  ++F[x+ex[i]][y+ey[i]];
	  M[x+ex[i]][y+ey[i]] = '!';
	  que_B.push({x+ex[i],y+ey[i]});
	}
      }
    }
    int W = 0, B = 0;
    for (int i = 0; i < h; ++i){
      for (int j = 0; j < w; ++j){
	if (F[i][j] == 1) ++B;
	if (F[i][j] == -1) ++W;
      }
    }
    cout << B << " " << W << endl;
  }
  return 0;
}