#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>

using namespace std;

const static int NONE  = 0x00;
const static int BLACK = 0x01;
const static int WHITE = 0x10;
const static int BOTH  = 0x11;

string getDummyLine( int w ) {
  string line = "";
  for( int c = 0; c < w + 2; c++ ) {
    line += "V";
  }
  return line;
}

int visit( vector<string>& island, int i, int j, int &counter ) {
  if( island[ i ][ j ] != '.' ) {
    if( island[ i ][ j ] == 'B' ) { return BLACK; }
    if( island[ i ][ j ] == 'W' ) { return WHITE; }
    return NONE;
  }

  counter++;
  island[ i ][ j ] = 'V';
  
  return (
      visit( island, i - 1, j     , counter ) |
      visit( island, i    , j - 1 , counter ) |
      visit( island, i + 1, j     , counter ) |
      visit( island, i    , j + 1, counter  ) 
  );
}

int main() {
  while( 1 ) {
    int w, h;
    vector<string> island;
    cin >> w >> h;
    if( !w && !h ) { return EXIT_SUCCESS; }

    string dummyLine = getDummyLine( w );
    island.push_back( dummyLine );
    for( int r = 1; r <= h; r++ ) {
      string line;
      cin >> line;
      island.push_back( 'V' + line + 'V' );
    }
    island.push_back( dummyLine );
    int blackNum = 0, whiteNum = 0;
    for( int r = 1; r <= h; r++ ) {
      for( int c = 1; c <= w; c++ ) {
        int size = 0;
        int type = visit( island, r, c, size );
        if( type == BLACK ) {
          blackNum += size;
        } else if( type == WHITE ) {
          whiteNum += size;
        }
      }
    }

    cout << blackNum << " " << whiteNum << endl;
  }
}