#include <iostream>
#include <deque>
#include <vector>

using namespace std;

const char BLACK_STONE = 0;
const char WHITE_STONE = 1;
const char EMPTY = 2;
const char AREA_EDGE = 3;

void decide_area(int i, int j, char color, vector<vector<char> >& board, deque<deque<bool> >& black, deque<deque<bool> >& white){
  if ((color == BLACK_STONE) && black[i][j])
    return;
  else if ((color == WHITE_STONE) && white[i][j])
    return;
  else if ((board[i][j] == color) || (board[i][j] == EMPTY)){
    if (color == BLACK_STONE){
      black[i][j] = true;
    }else if (color == WHITE_STONE){
      white[i][j] = true;
    }
    decide_area(i,j+1,color,board,black,white);
    decide_area(i-1,j,color,board,black,white);
    decide_area(i,j-1,color,board,black,white);
    decide_area(i+1,j,color,board,black,white);
  }else{
    return;
  }
}

void calc_area(vector<vector<char> >& board, int& black, int& white){
  deque<deque<bool> > d_d_black(board.size(),deque<bool>(board[0].size(), false)), d_d_white(board.size(), deque<bool>(board[0].size(), false));
  for (int i = 1; i < ((int)board.size()-1); i++){
    for (int j = 1; j < ((int)board[i].size()-1); j++){
      if (board[i][j] != EMPTY){
        decide_area(i,j,board[i][j],board,d_d_black,d_d_white);
      }
    }
  }

  black = 0;
  white = 0;  
  for (int i = 1; i < ((int)board.size()-1); i++){
    for (int j = 1; j < ((int)board[i].size()-1);j++){
      if ((board[i][j] == EMPTY) && d_d_black[i][j] && !d_d_white[i][j]){
        black++;
      }else if ((board[i][j] == EMPTY) && !d_d_black[i][j] && d_d_white[i][j]){
        white++;
      }
    }
  }
}

int main(){
  int n,m;
  while(cin >> m >> n){
    if ((n == 0) && (m == 0))
      break;
    vector<vector<char> > b(n+2,vector<char>(m+2,EMPTY));
    for (int i = 0; i < n+2; i++){
      b[i][0] = AREA_EDGE;
      b[i][m+1] = AREA_EDGE;
    }
    for (int j = 0; j < m+2; j++){
      b[0][j] = AREA_EDGE;
      b[n+1][j] = AREA_EDGE;
    }
    for (int i = 1; i < n+1; i++){
      for (int j = 1; j < m+1; j++){
        char t;
        cin >> t;
        if (t == 'B')
          b[i][j] = BLACK_STONE;
        else if (t == 'W')
          b[i][j] = WHITE_STONE;
        else if (t == '.')
          b[i][j] = EMPTY;
      }
    }

    int black,white;
    calc_area(b,black,white);

    cout << black << ' ' << white << endl;
  }

  return 0;
}