import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

int H, W;
string[] F;
bool input() {
    scanf("%d %d\n", &W, &H);
    if (W == 0 && H == 0) return false;
    F = new string[H];
    foreach (i; 0 .. H) {
        F[i] = readln.chomp;
    }
    return true;
}

const dy = [-1, 0, 1, 0],
      dx = [0, -1, 0, 1];

void solve() {
    auto M = new int[][](H, W);
    int ans_b, ans_w;

    void fill(int y, int x, int v) {
        struct P {
            int y, x;
        }
        int f = 0;
        auto Q = new DList!P(P(y, x));
        while (!Q.empty) {
            P c = Q.front; Q.removeFront;
            foreach (i; 0 .. 4) {
                int ny = c.y + dy[i],
                    nx = c.x + dx[i];
                if (ny < 0 || ny >= H) continue;
                if (nx < 0 || nx >= W) continue;
                if (M[ny][nx] & v) continue;
                if (F[ny][nx] != '.') continue;
                M[ny][nx] |= v;
                Q.insert(P(ny, nx));
            }
        }
    }

    foreach (i; 0 .. H) {
        foreach (j; 0 .. W) {
            char c = F[i][j];
            if (c == 'B') {
                fill(i, j, 1);
            } else if (c == 'W') {
                fill(i, j, 2);
            }
        }
    }
    foreach (i; 0 .. H) {
        foreach (j; 0 .. W) {
            if (F[i][j] == '.' && M[i][j] == 1) {
                ans_b++;
            } else if (F[i][j] == '.' && M[i][j] == 2) {
                ans_w++;
            }
        }
    }
    writeln(ans_b, " ", ans_w);
}

void main() {
    while (input) solve;
}