#! /usr/bin/python
# -*- coding: utf-8 -*-

def dfs(Map, used, i, j):
    cnt = 0
    wc = False
    bc = False
    q = [[i, j]]
    used[i][j] = True
    while q!=[]:
        cnt += 1
        i = q[0][0]
        j = q[0][1]
        if Map[i][j] == 'W':
            wc = True
        elif Map[i][j] == 'B':
            bc = True
        q.pop(0)
        if i-1>=0:
            if Map[i-1][j] == 'W':
                wc = True
            elif Map[i-1][j] == 'B':
                bc = True
            elif used[i-1][j] == False:
                q.append([i-1, j])
                used[i-1][j] = True
        if i+1<len(used):
            if Map[i+1][j] == 'W':
                wc = True
            elif Map[i+1][j] == 'B':
                bc = True
            elif used[i+1][j] == False:
                q.append([i+1, j])
                used[i+1][j] = True
        if j-1>=0:
            if Map[i][j-1] == 'W':
                wc = True
            elif Map[i][j-1] == 'B':
                bc = True
            elif used[i][j-1] == False:
                q.append([i, j-1])
                used[i][j-1] = True
        if j+1<len(used[i]):
            if Map[i][j+1] == 'W':
                wc = True
            elif Map[i][j+1] == 'B':
                bc = True
            elif used[i][j+1] == False:
                q.append([i, j+1])
                used[i][j+1] = True
    if wc == True and bc == True:
        return int(0)
    elif wc == True:
        return -int(cnt)
    elif bc == True:
        return int(cnt)
    else:
        return 0

while 1:
    (w, h) = map(int, raw_input().split())
    if w==0: break
    M = []
    [wr, br] = [0, 0]
    for i in range(h):
        M.append(raw_input())
    used = [[False]*w for i in range(h)]
    for i in range(h):
        for j in range(w):
            if M[i][j] in ('W','B'): used[i][j] = True
    for i in range(h):
        for j in range(w):
            if used[i][j] == False:
                s = dfs(M, used, i, j)
                if s < 0:
                    wr -= s
                elif s > 0:
                    br += s
    print br, wr
            