#include <bits/stdc++.h>
using namespace std;

const int INF = 1000000007;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pr;

char field[50][54];
int w, h;

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

int group[50][50];

void dfs(int x, int y, int c){
    if((group[x][y] & c) > 0) return;
    group[x][y] |= c;
    for(int i = 0; i < 4; i++){
        int nx = x + dx[i], ny = y + dy[i];
        if(0 <= nx && nx < h && 0 <= ny && ny < w &&
                field[nx][ny] == '.'){
            dfs(nx, ny, c);
        }
    }
}

int main(){
    while(true){
        scanf("%d%d", &w, &h);
        if(w == 0 && h == 0) break;
        for(int i = 0; i < h; i++){
            scanf(" %s", field[i]);
        }
        for(int i = 0; i < h; i++){
            fill(group[i], group[i] + w, 0);
        }
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(field[i][j] == 'B'){
                    dfs(i, j, 1);
                }else if(field[i][j] == 'W'){
                    dfs(i, j, 2);
                }
            }
        }
        int black = 0, white = 0;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(field[i][j] != '.') continue;
                if(group[i][j] == 1){
                    ++black;
                }
                if(group[i][j] == 2){
                    ++white;
                }
            }
        }
        printf("%d %d\n", black, white);
    }
    return 0;
}