from collections import deque
def bfs(y,x):
    q = deque()
    q.append((y,x))
    bfs_map[y][x] = 0
    res = 0
    su = 1
    while q:
        y,x = q.popleft()
        for dy,dx in d:
            y_ = y+dy
            x_ = x+dx
            if 0 <= y_ < h and 0 <= x_ < w:
                res |= f[s[y_][x_]]
                if bfs_map[y_][x_]:
                    bfs_map[y_][x_] = 0
                    if not f[s[y_][x_]]:
                        q.append((y_,x_))
                        su += 1
    return res,su
d = [(1,0),(-1,0),(0,1),(0,-1)]
while 1:
    w,h = map(int, input().split())
    if w == h == 0:
        break
    s = [input() for i in range(h)]
    bfs_map = [[1 for j in range(w)] for i in range(h)]
    f = {".":0, "B":1, "W":2}
    ans = [0,0,0,0]
    for y in range(h):
        for x in range(w):
            if bfs_map[y][x] and s[y][x] == ".":
                k,su = bfs(y,x)
                ans[k] += su
    print(*ans[1:3])

