from collections import deque

dxs = [1,0,-1,0]
dys = [0,1,0,-1]
def bfs(x,y,c):
    q = deque([(x,y)])
    while q:
        x,y = q.popleft()
        for dx,dy in zip(dxs,dys):
            nx,ny = x+dx,y+dy
            if nx < 0 or nx >= W or ny < 0 or ny >= H: continue
            if src[ny][nx] != '.' or mem[c][ny][nx]: continue
            q.append((nx,ny))
            mem[c][ny][nx] = 1

while True:
    W,H = map(int,input().split())
    if W == 0: break
    src = [input() for i in range(H)]
    mem = [[[0 for w in range(W)] for h in range(H)] for c in range(2)]
    for y in range(H):
        for x in range(W):
            if src[y][x] == '.': continue
            c = (0 if src[y][x] == 'B' else 1)
            bfs(x,y,c)
    b = w = 0
    for y in range(H):
        for x in range(W):
            bm,wm = mem[0][y][x], mem[1][y][x]
            if bm and not wm: b += 1
            elif wm and not bm: w += 1
    print(str(b) + ' ' + str(w))