dx=(1,-1,0,0)
dy=(0,0,1,-1)

def dfsW(y,x):
    if L[y][x]==".":
        L[y][x]="P"
    for i in range(4):
        mx=x+dx[i]
        my=y+dy[i]
        if 0<=mx<w and 0<=my<h and L[my][mx]==".":
            dfsW(my,mx)

def dfsB(y,x):
    if L[y][x]==".":
        L[y][x]="Q"
    elif L[y][x]=="P":
        L[y][x]="N"
    for i in range(4):
        mx=x+dx[i]
        my=y+dy[i]
        if 0<=mx<w and 0<=my<h and (L[my][mx]=="." or L[my][mx]=="P"):
            dfsB(my,mx)

while True:
    w,h=map(int,raw_input().split())
    if w==h==0:break
    L=[list(raw_input()) for i in range(h)]
    for i in range(h):
        for j in range(w):
            if L[i][j]=="W":
                dfsW(i,j)
    for i in range(h):
        for j in range(w):
            if L[i][j]=="B":
                dfsB(i,j)
    cntW=cntB=0
    for i in range(h):
	cntW+=L[i].count("P")
	cntB+=L[i].count("Q")
    print cntB,cntW