#include <iostream>
#include <queue>
#include <cstring>

using namespace std;

struct State {
  int x, y;
  State(int x, int y): x(x), y(y) {;}
};

const int MAX_N = 50;
const int dx[] = {0, 1, 0, -1},
          dy[] = {-1, 0, 1, 0};

int W, H;
char field[MAX_N][MAX_N];
bool visit[MAX_N][MAX_N];

int bfs(int sx, int sy, char color)
{
  queue<State> que;
  que.push(State(sx, sy));
  bool flag = true;
  int ret = 0;
  while (!que.empty()) {
    State s = que.front(); que.pop();
    int x = s.x, y = s.y;

    if (x < 0 || x >= W || y < 0 || y >= H || visit[y][x] || field[y][x] == color)
      continue;

    if (field[y][x] != '.')
      flag = false;

    visit[y][x] = true;
    ret++;

    for (int k = 0; k < 4; k++) 
      que.push(State(x + dx[k], y + dy[k]));
  }

  return flag ? ret : 0;
}

int solve(char c)
{
  memset(visit, false, sizeof(visit));
  int sol = 0, sc = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (!visit[i][j]) {
        int val = bfs(j, i, c);
        sol += val;
        sc++;
      }
    }
  }

  return (sc > 1) ? sol : 0;
}

int main()
{
  while (cin >> W >> H && W && H) {
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cin >> field[i][j];
      }
    }

    cout << solve('B') << " " << solve('W') << endl;
  }
}