#include <bits/stdc++.h>

using namespace std;

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

void bfs(int c[][64], queue<pair<int, int> > q, int w, int h, int bit)
{
    for (; q.size(); q.pop()){
        pair<int, int> pos = q.front();
        
        for (int i = 0; i < 4; i++){
            pair<int, int> npos = make_pair(pos.first + dy[i], pos.second + dx[i]);
            
            if (0 <= npos.first && npos.first < h && 0 <= npos.second && npos.second < w){
                if ((c[npos.first][npos.second] & bit) == 0){
                    c[npos.first][npos.second] |= bit;
                    q.push(npos);
                }
            }
        }
    }
    
}

int main()
{
    int w, h;
    
    while (scanf("%d %d", &w, &h) && w){
        char mp[64];
        int c[64][64] = {0};
        
        queue<pair<int, int> > Bs, Ws;
        
        for (int i = 0; i < h; i++){
            scanf("%s", mp);
            for (int j = 0; j < 64; j++){
                if (isalpha(mp[j])){
                    c[i][j] = -1;
                    if (mp[j] == 'W') Ws.push(make_pair(i, j));
                    else Bs.push(make_pair(i, j));
                }
            }
        }
        
        bfs(c, Bs, w, h, 1);
        bfs(c, Ws, w, h, 2);
        
        int black = 0, white = 0;
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if (c[i][j] == 1) black++;
                else if (c[i][j] == 2) white++;
            }
        }
        
        printf("%d %d\n", black, white);
    }
    
    return (0);
}