#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;

int h, w;
char a[60][60];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, -1, 0, 1};

bool in(int x, int y) { return 0 <= x && x < h && 0 <= y && y < w; }
void solve(int x, int y, char c)
{
    if (a[x][y] == '.')
        a[x][y] = c;
    if (a[x][y] == 'w' || a[x][y] == 'b')
    {
        if (a[x][y] != c)
            a[x][y] = 'm';
    }
    for (int i = 0; i < 4; i++)
    {
        int nx = x + dx[i], ny = y + dy[i];
        if (!in(nx, ny) || a[nx][ny] == 'W' || a[nx][ny] == 'B' || a[nx][ny] == 'm' || a[nx][ny] == c)
            continue;
        solve(nx, ny, c);
    }
}

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

    while (1)
    {
        cin >> w >> h;
        if (w == 0)
            break;
        rep(i, h) rep(j, w) cin >> a[i][j];
        int sum1 = 0, sum2 = 0;
        rep(i, h) rep(j, w)
        {
            if (a[i][j] == 'W')
                solve(i, j, 'w');
            if (a[i][j] == 'B')
                solve(i, j, 'b');
        }
        rep(i, h)
        {
            rep(j, w)
            {
                if (a[i][j] == 'b')
                    sum1++;
                if (a[i][j] == 'w')
                    sum2++;
            }
        }
        cout << sum1 << " " << sum2 << endl;
    }
}
