#include <iostream>
using namespace std;

int w, h, cnt;
char cmp;
char field[50][50];
int dx[] = { -1, 0, 1, 0 };
int dy[] = { 0, -1, 0, 1 };

bool search( int sx, int sy ){
    cnt++;
    field[sy][sx] = '#';
    bool ans = true;
    for( int i = 0; i < 4; i++ ){
        int x = sx + dx[i];
        int y = sy + dy[i];
        if( 0 <= x && x < w && 0 <= y && y < h && field[y][x] != '#' ){
            if( field[y][x] == 'B' || field[y][x] == 'W' ){
                if( cmp == '.' ) cmp = field[y][x];
                else if( cmp != field[y][x] ) ans =  false;
            }else if( !search( x, y ) ) ans = false;
        }
    }
    return ans;
}

int main(){
    while( cin >> w >> h && w ){
        for( int i = 0; i < h; i++ ){
            for( int j = 0; j < w; j++ ){
                cin >> field[i][j];
            }
        }
        int cnt_b = 0, cnt_w = 0;
        for( int i = 0; i < h; i++ ){
            for( int j = 0; j < w; j++ ){
                cnt = 0;
                cmp = '.';
                if( field[i][j] == '.' ){
                    if( search( j, i ) ){
                        if( cmp == 'B' ) cnt_b += cnt;
                        else if( cmp == 'W' ) cnt_w += cnt;
                    }
                }
            }
        }
        cout << cnt_b << ' ' << cnt_w << endl;
    }
}