#include <bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int W, H;
string s[51];
bool visited[51][51];
bool dfs(int y, int x, char c) {
    if (s[y][x] != '.' && s[y][x] != c) return false;
    if (s[y][x] == c) return true;
    bool ret = true;
    rep(k, 4) {
        int ny = y + dy[k];
        int nx = x + dx[k];
        if (ny < 0 || nx < 0) continue;
        if (H <= ny || W <= nx) continue;
        if (visited[ny][nx]) continue;
        if (s[y][x] != '.') continue;
        visited[ny][nx] = true;
        ret &= dfs(ny, nx, c);
    }
    return ret;
}
void solve() {
    int ans1 = 0, ans2 = 0;
    int cnt = 0;
    rep(i, H) rep(j, W) {
        if (s[i][j] == '.') cnt++;
        if (s[i][j] != '.') continue;
        if (dfs(i, j, 'B')) ans1++;
        memset(visited, 0, sizeof(visited));
        if (dfs(i, j, 'W')) ans2++;
        memset(visited, 0, sizeof(visited));
    }
    if (cnt == H * W) {
        cout << "0 0" << endl;
    } else {
        cout << ans1 << " " << ans2 << endl;
    }
}
int main() {
    while (cin >> W >> H, W) {
        rep(i, H) cin >> s[i];
        solve();
    }
    return 0;
}
/*
.....W....
....W.W...
...W...W..
....W...W.
.....W...W
......W.W.
BBB....W..
..B..BBBBB
..B..B....
..B..B..W.
*/