#include <iostream>
#include <queue>
using namespace std;
typedef pair<int,int> P;
int W,H;
int visited[51][51] = {};
char A[51][51];

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

bool in(int x,int y){
    return 1<=x && x<=H && 1<=y && y<=W;
}

void init(){
    for(int i=1;i<=H;i++) for(int j=1;j<=W;j++) visited[i][j] = 0;
}

int main(){
    while(cin >> W >> H && W>0){
        for(int i=1;i<=H;i++) for(int j=1;j<=W;j++) cin >> A[i][j];
        int black = 0,white = 0;
        for(int i=1;i<=H;i++){
            for(int j=1;j<=W;j++){
                if(A[i][j]!='.') continue;
                init();
                visited[i][j] = 1;
                queue<P> Q;
                Q.push({i,j});
                bool b = false,w = false;
                while(!Q.empty()){
                    int x = Q.front().first,y = Q.front().second;
                    Q.pop();
                    for(int i=0;i<4;i++){
                        int nx = x+dx[i],ny = y+dy[i];
                        if(!in(nx,ny)) continue;
                        if(visited[nx][ny]==1) continue;
                        if(A[nx][ny]=='W') w = true;
                        if(A[nx][ny]=='B') b = true;
                        if(A[nx][ny]=='.'){
                            visited[nx][ny] = 1;
                            Q.push({nx,ny});
                        }
                    }
                }
                if(b&&!w) black++;
                if(!b&&w) white++;
            }
        }
        cout << black << " " << white << endl;
    }
}
