import sys
def ds4(here, lb, ub, field, label):
	if not field[here[1]][here[0]][label]:
		field[here[1]][here[0]][label] = True
	
		if lb[0] < here[0]:
			ds4((here[0]-1, here[1]), lb, ub, field, label)

		if lb[1] < here[1]:
			ds4((here[0], here[1]-1), lb, ub, field, label)
			
		if ub[0] > here[0]:
			ds4((here[0]+1, here[1]), lb, ub, field, label)
			
		if ub[1] > here[1]:
			ds4((here[0], here[1]+1), lb, ub, field, label)

sys.setrecursionlimit(10000)	
while 1:
	w,h = map(int,raw_input().split())
	if (w,h) == (0,0):
		break
	W = []
	B = []
	island = [[[False, False] for i in range(w)] for j in range(h)]
	for j in range(h):
		s = raw_input()
		for i in range(w):
			if s[i] == "B":
				island[j][i][0] = True
				B.append((i,j))
			elif s[i] == "W":
				island[j][i][1] = True
				W.append((i,j))
	for wh in W:
		ds4(wh,(0,0),(w-1,h-1),island,0)
	for bl in B:
		ds4(bl,(0,0),(w-1,h-1),island,1)
	wnum = bnum = 0
	for j in range(h):
		for i in range(w):
			if island[j][i][0]^island[j][i][1]:	
				if island[j][i][0] and not island[j][i][1]:
					wnum += 1
				elif island[j][i][1] and not island[j][i][0]:
					bnum += 1
	print bnum, wnum