#include <iostream>
#include <string>
#include <vector>
using namespace std;

void dfs(int y, int x, vector<string> const& v, vector<vector<bool>>& v2) {
    int dx[4] = {0, -1, 0, 1}, dy[4] = {1, 0, -1, 0};
    
    for(int i=0; i<4; ++i) {
        int nx = x + dx[i], ny = y + dy[i];
        if(0 <= nx && nx < v[0].size() && 0 <= ny && ny < v.size() && v[ny][nx] == '.' && !v2[ny][nx]) {
            v2[ny][nx] = true;
            dfs(ny, nx, v, v2);
        } 
    }
}

int main() {
    int w, h;
    while(cin >> w >> h, w) {
        vector<string> v(h);
        vector<vector<bool>> B(h, vector<bool>(w, false));
        vector<vector<bool>> W(h, vector<bool>(w, false));
        for(int i=0; i<v.size(); ++i) {
            cin >> v[i];
        }

        for(int i=0; i<v.size(); ++i) {
            for(int j=0; j<v[i].size(); ++j) {
                if(v[i][j] == 'W') {
                    dfs(i, j, v, W);
                } else if(v[i][j] == 'B') {
                    dfs(i, j, v, B);
                }
            }
        }

        int ans_w = 0, ans_b = 0;
        for(int i=0; i<h; ++i) {
            for(int j=0; j<w; ++j) {
                if(!B[i][j] && W[i][j]) {
                    ans_w++;
                }
                if(B[i][j] && !W[i][j]) {
                    ans_b++;
                }
            }
        }
        cout << ans_b << " " << ans_w << endl;
    }
}
