#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstdio>
#include<cstring>
#include<string>

#define REP(i,n) for(int i=0;i<(n);i++)

int di[4] = {1, 0, -1, 0};
int dj[4] = {0, 1, 0, -1};
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int w, h;
char field[51][51];
bool visited[51][51];
bool white_flg;
bool black_flg;

int dfs(int i, int j){
    if(i<0 || h<=i || j<0 || j>=w || visited[i][j]) return 0;
    if(field[i][j] == 'B'){
        black_flg = true;
        return 0;
    }
    if(field[i][j] == 'W'){
        white_flg = true;
        return 0;
    }
    visited[i][j] = true;
    int res = 1;
    REP(k,4){
        res += dfs(i+di[k], j+dj[k]);
    }
    return res;
}

int main(){
    while(cin >> w >> h){
        if(w+h==0) break;
        int white = 0;
        int black = 0;
        memset(visited, false, sizeof(visited));
        REP(i,h) cin >> field[i];

        REP(i,h){
            REP(j,w){
                if(!visited[i][j] && field[i][j] == '.'){
                    white_flg = false;
                    black_flg = false;
                    int s = dfs(i,j);
                    if(white_flg && !black_flg) white += s;
                    else if(black_flg && !white_flg) black += s;
                }
            }
        }
        cout << black << ' ' << white << endl;
    }
    return 0;
}