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

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            w, h = map(int, raw_input().split())
            if w == h == 0:
                break
            m = []
            for i in range(1, h+1):
                row = list(raw_input())
                m.append(row)
            # for row in m:
            #     print row
            # print 
            d = [(0, 1), (1, 0), (0, -1), (-1, 0)]
            w_count = 0
            b_count = 0
            for i in range(h):
                for j in range(w):
                    if m[i][j] == '.':
                        q = [(i, j)]
                        flg = None
                        count = 0
                        while q:
                            y, x = q.pop()
                            if m[y][x] == '.':
                                count += 1
                            m[y][x] = 'U'
                            for dy, dx in d:
                                if 0 <= y + dy < h and 0 <= x + dx < w:
                                    if m[y+dy][x+dx] == 'W':
                                        if flg is None:
                                            flg = 'W'
                                        elif flg == 'B':
                                            flg = 'NotOccupied'
                                    elif m[y+dy][x+dx] == 'B':
                                        if flg is None:
                                            flg = 'B'
                                        elif flg == 'W':
                                            flg = 'NotOccupied'
                                    elif m[y+dy][x+dx] == '.':
                                        q.append((y + dy, x + dx))
                                                                            
                        if flg == 'W':
                            w_count += count
                        elif flg == 'B':
                            b_count += count
                        # for row in m:
                        #     print row
                        # print b_count, w_count
                        # print 
                            
            print b_count, w_count
                                                
                                    
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()