#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

typedef pair<int, int> P;

int h, w;
string field[51];

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

char bfs(int y, int x){
  if(field[y][x] != '.') return '.';
  queue<P> que;
  set<P> check;
  que.push(P(y, x));
  bool isW, isB;
  isW = isB = false;
  while(!que.empty()){
    if(isW && isB) return '.';
    P pos = que.front();
    que.pop();
    if(check.find(pos) != check.end()) continue;
    check.insert(pos);
    for(int i = 0 ; i < 4 ; i++){
      if(pos.first+dy[i] < 0 || pos.first+dy[i] >= h) continue;
      if(pos.second+dx[i] < 0 || pos.second+dx[i] >= w) continue;
      
      if(field[pos.first+dy[i]][pos.second+dx[i]] == 'W'){
	isW = true;
	continue;
      }
      else if(field[pos.first+dy[i]][pos.second+dx[i]] == 'B'){
	isB = true;
	continue;
      }
      else{
	que.push(P(pos.first+dy[i], pos.second+dx[i]));
      }
    }
  }
  
  if(isW && !isB) return 'W';
  else if(!isW && isB) return 'B';
  else return '.';
}

int main(){
  while(cin >> w >> h){
    if(h == 0 && w == 0) break;
    for(int i = 0 ; i < h ; i++){
      cin >> field[i];
    }
    
    int W, B;
    W = B = 0;

    for(int i = 0 ; i < h ; i++){
      for(int j = 0 ; j < w ; j++){
	char c = bfs(i, j);
	if(c == 'W') W++;
	else if(c == 'B') B++;
      }
    }
    cout << B << ' ' << W << endl;
  }
  return 0;
}