#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

int H, W;
string s[100];
bool done[100][100];
bool adj1, adj2;

bool inside(int x, int y) {
    return 0 <= x && x < H && 0 <= y && y < W;
}

void dfs(int x, int y) {
    if (!inside(x, y)) return;
    if (done[x][y]) return;
    if (s[x][y] == 'W') {
        adj1 = true;
        return;
    }
    if (s[x][y] == 'B') {
        adj2 = true;
        return;
    }

    done[x][y] = true;
    dfs(x + 1, y);
    dfs(x - 1, y);
    dfs(x, y + 1);
    dfs(x, y - 1);
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    while (cin >> W >> H, W) {
        int n1 = 0, n2 = 0;
        rep(i, H) cin >> s[i];

        rep(i, H) {
            rep(j, W) {
                if (s[i][j] == '.') {
                    adj1 = false, adj2 = false;
                    rep(k, H) rep(l, W) done[k][l] = false;
                    dfs(i, j);
                    if (adj1 && !adj2) n1++;
                    if (!adj1 && adj2) n2++;
                }
            }
        }

        cout << n2 << " " << n1 << endl;
    }
}