#include <bits/stdc++.h>
int width, height;
int map[50][50];
char input_map[50][51];
int main(void) {
  int i, j, k;
  int black, white;
  while (1) {
    scanf("%d%d", &width, &height);
    if (width == 0 && height == 0) break;
    memset(map, 0, sizeof(map));
    for (i = 0; i < height; i++) {
      scanf("%s", input_map[i]);
      for (j = 0; j < width; j++) {
        if (input_map[i][j] == 'B')
          map[i][j] = 5;
        else if (input_map[i][j] == 'W')
          map[i][j] = 6;
      }
    }
    for (k = 0; k < width + height; k++) {
      for (i = 0; i < height; i++) {
        for (j = 0; j < width; j++) {
          if ((map[i][j] & 4) == 0) {
            if (i > 0) map[i][j] |= map[i - 1][j] & 3;
            if (j > 0) map[i][j] |= map[i][j - 1] & 3;
            if (i < height - 1) map[i][j] |= map[i + 1][j] & 3;
            if (j < width - 1) map[i][j] |= map[i][j + 1] & 3;
          }
        }
      }
    }
    black = white = 0;
    for (i = 0; i < height; i++) {
      for (j = 0; j < width; j++) {
        if (map[i][j] == 1)
          black++;
        else if (map[i][j] == 2)
          white++;
      }
    }
    printf("%d %d\n", black, white);
  }
  return 0;
}
