using System;

public class Hello
{
    public static void Main()
    {
        var dx = new int[] { 0, 1, 0, -1 };
        var dy = new int[] { 1, 0, -1, 0 };
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var w = int.Parse(line[0]);
            var h = int.Parse(line[1]);
            if (w == 0 && h == 0) break;
            var map1 = new int[h, w]; var map2 = new int[h, w];
            for (int i = 0; i < h; i++)
            {
                var s = Console.ReadLine().Trim();
                for (int j = 0; j < w; j++)
                    if (s[j] == 'B') { map1[i, j] = 1; map2[i, j] = 1; }
                    else if (s[j] == 'W') { map1[i, j] = 2; map2[i, j] = 2; }
            }
            for (int i = 0; i < h; i++)
                for (int j = 0; j < w; j++)
                {
                    if (map1[i, j] == 1) goDfs(map1, dx, dy, i, j);
                    if (map2[i, j] == 2) goDfs(map2, dx, dy, i, j);
                }
            var wcount = 0; var bcount = 0;
            for (int i = 0; i < h; i++)
                for (int j = 0; j < w; j++)
                {
                    if (map1[i, j] == 0) wcount++;
                    if (map2[i, j] == 0) bcount++;
                }
            Console.WriteLine("{0} {1}", bcount, wcount);
        }
    }
    public static void goDfs(int[,] map, int[] dx, int[] dy, int x, int y)
    {
        var h = map.GetLength(0); var w = map.GetLength(1);
        if (map[x, y] == 0) map[x, y] = 10;
        for (int i = 0; i < 4; i++)
        {
            var nx = x + dx[i];
            var ny = y + dy[i];
            if (nx >= 0 && nx < h && ny >= 0 && ny < w && map[nx, ny] == 0)
                goDfs(map, dx, dy, nx, ny);
        }
    }
}