#include <iostream>
#include <vector>
using namespace std;

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

const int black = 0x01;
const int white = 0x02;

int search(vector<vector<char> >& map, int y, int x, int& whose){
    if(map[y][x]=='A'){
        return 0;
    }
    if(map[y][x]=='B'){
        whose|=black;
        return 0;
    }
    if(map[y][x]=='W'){
        whose|=white;
        return 0;
    }
    map[y][x] = 'A';
    
    int count=1;
    for(int i=0; i<4; i++){
        count += search(map, y+dy[i], x+dx[i], whose);
    }
    return count;
}

int main(){
    while(1){
        int w,h;
        cin >> w >> h;
        if(w==0) break;

        vector<vector<char> > map(h+2, vector<char>(w+2, 'A'));
        for(int i=1; i<=h; i++){
            for(int j=1; j<=w; j++){
                cin >> map[i][j];
            }
        }

        int bcount=0;
        int wcount=0;
        for(int i=1; i<=h; i++){
            for(int j=1; j<=w; j++){
                if(map[i][j]=='.'){
                    int whose=0; // 1:black 2:white 3:both
                    int count=0;
                    count = search(map, i, j, whose);
                    if(whose==1){
                        bcount+=count;
                    }else if(whose==2){
                        wcount+=count;
                    }
                }
            }
        }

        cout << bcount << " " << wcount << endl;
    }
    return 0;
}