#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

struct State { int b, w, empty; };
State operator+(const State& a, const State& b) {
    return { a.b+b.b, a.w+b.w, a.empty+b.empty };
}
int dir[] = { -1, 0, 1, 0, -1 };

int w, h;
vector<string> A;
vector<vector<int>> vis;

State dfs(int y, int x) {
    if (y < 0 || y >= h || x < 0 || x >= w) return { 0, 0, 0 };
    if (A[y][x] == 'B') return { 1, 0, 0 };
    if (A[y][x] == 'W') return { 0, 1, 0 };
    if (vis[y][x]) return { 0, 0, 0 };
    vis[y][x] = 1;
    if (A[y][x] == '.') {
        State sum = { 0, 0, 1 };
        loop (4, i) sum = sum + dfs(y + dir[i], x + dir[i + 1]);
        return sum;
    }
}

int main()
{
    while (1) {
        cin >> w >> h;
        if (!w) break;
        A = vector<string>(h);
        vis = vector<vector<int>>(h, vector<int>(w));

        loop (h, i) cin >> A[i];

        int ans_b = 0, ans_w = 0;
        loop (h, i) loop (w, j) {
            auto rt = dfs(i, j);
            if (rt.b && rt.w) continue;
            if (rt.b) ans_b += rt.empty;
            if (rt.w) ans_w += rt.empty;
        }

        cout << ans_b << " " << ans_w << endl;
    }
    return 0;
}