#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const int MAXW = 50, MAXH = 50;

const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, 1, 0, -1};

int w, h;
string a[MAXH];
bool visited[MAXH][MAXW];
bool iswhite, isblack;
int cnt = 0;
int answ = 0, ansb = 0;

void dfs(int i, int j){
    visited[i][j] = true;
    cnt++;
    for(int k=0;k<4;k++){
        if(i + di[k] < 0 || i + di[k] >= h || j + dj[k] < 0 || j + dj[k] >= w) continue;
        if(a[i + di[k]][j + dj[k]] == 'W') iswhite = true;
        else if(a[i + di[k]][j + dj[k]] == 'B') isblack = true;
        else if(!visited[i + di[k]][j + dj[k]]) dfs(i + di[k], j + dj[k]);
    }
}

void solve(int i, int j){
    iswhite = false, isblack = false;
    cnt = 0;

    dfs(i, j);

    if(iswhite && !isblack){
        answ += cnt;
    }else if(isblack && !iswhite){
        ansb += cnt;
    }
}


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    while(1){
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        for(int i=0;i<h;i++){
            cin >> a[i];
        }
        // initialization
        memset(visited, 0, sizeof visited);
        ansb = 0, answ = 0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(a[i][j] == '.' && !visited[i][j]){
                    solve(i, j);
                }
            }
        }
        cout << ansb << " " << answ << endl;
    }
}
