# coding: utf-8
import queue
while 1:
    w,h=map(int,input().split())
    if w==0:
        break
    field=[]
    for i in range(h):
        field.append(list(input()))
    B=0
    W=0
    for i in range(h):
        for j in range(w):
            if field[i][j]=='.':
                q=queue.Queue()
                q.put((i,j))
                check=set()
                d=0
                while not q.empty():
                    y,x=q.get()
                    if field[y][x]=='.':
                        field[y][x]='#'
                        d+=1
                    elif field[y][x]=='W':
                        check.add('W')
                        continue
                    elif field[y][x]=='B':
                        check.add('B')
                        continue
                    else:
                        continue
                    if 0<=y+1<h and 0<=x<w:
                        q.put((y+1,x))
                    if 0<=y-1<h and 0<=x<w:
                        q.put((y-1,x))
                    if 0<=y<h and 0<=x+1<w:
                        q.put((y,x+1))
                    if 0<=y<h and 0<=x-1<w:
                        q.put((y,x-1))
                if len(check)==2:
                    pass
                elif 'B' in check:
                    B+=d
                elif 'W' in check:
                    W+=d
    print(B,W)
