#include <bits/stdc++.h>
using namespace std;
int w, h;
string grid[55], col[55];
bool vis[55][55];
int dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1};
int count(char color) {
  int res = 0;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      if (col[i][j] == color) res++;
  return res;
}
void rec(int y, int x, int color) {
  if (vis[y][x]) return;
  vis[y][x] = true;
  if (grid[y][x] == '.') {
    if (col[y][x] == '.' || col[y][x] == color)
      col[y][x] = color;
    else
      col[y][x] = 'G';
  }
  for (int d = 0; d < 4; d++) {
    int ny = y + dy[d], nx = x + dx[d];
    if (ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
    if (grid[ny][nx] != '.') continue;
    rec(ny, nx, color);
  }
}
int main() {
  while (cin >> w >> h, w) {
    for (int i = 0; i < h; i++) {
      cin >> grid[i];
      col[i] = "";
      for (int j = 0; j < w; j++) col[i] += '.';
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (grid[i][j] != '.') {
          memset(vis, 0, sizeof(vis));
          rec(i, j, grid[i][j]);
        }
      }
    }
    cout << count('B') << " " << count('W') << endl;
  }
}
