#include <bits/stdc++.h>
int dmap[50][50];
int bmap[50][50];
int wmap[50][50];
int pmap[50][50];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {-1, 0, 1, 0};
int w, h;
void bdfs(int, int);
void wdfs(int, int);
int main() {
  int i, j, ansb, answ, k, l;
  char input;
  while (1) {
    scanf("%d %d", &w, &h);
    if (w == 0 && h == 0) break;
    for (i = 0; i < h; i++) {
      getchar();
      for (j = 0; j < w; j++) {
        scanf("%c", &input);
        if (input == 'B') {
          dmap[i][j] = 1;
        } else if (input == 'W') {
          dmap[i][j] = 2;
        } else {
          dmap[i][j] = 0;
        }
        bmap[i][j] = 0;
        wmap[i][j] = 0;
      }
    }
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
        for (k = 0; k < h; k++) {
          for (l = 0; l < w; l++) {
            pmap[k][l] = 0;
          }
        }
        bdfs(i, j);
      }
    }
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
        for (k = 0; k < h; k++) {
          for (l = 0; l < w; l++) {
            pmap[k][l] = 0;
          }
        }
        wdfs(i, j);
      }
    }
    ansb = 0;
    answ = 0;
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
        if (dmap[i][j]) continue;
        if (bmap[i][j] && !wmap[i][j])
          ansb++;
        else if (!bmap[i][j] && wmap[i][j]) {
          answ++;
        }
      }
    }
    printf("%d %d\n", ansb, answ);
  }
  return 0;
}
void bdfs(int y, int x) {
  if (pmap[y][x]) return;
  if (dmap[y][x]) return;
  pmap[y][x] = 1;
  int tx, ty, i;
  for (i = 0; i < 4; i++) {
    tx = dx[i] + x;
    ty = dy[i] + y;
    if (tx < 0 || tx >= w) continue;
    if (ty < 0 || ty >= h) continue;
    if (dmap[ty][tx] == 1) {
      bmap[y][x] = 1;
    } else if (bmap[ty][tx]) {
      bmap[y][x] = 1;
    }
    bdfs(ty, tx);
  }
  return;
}
void wdfs(int y, int x) {
  if (pmap[y][x]) return;
  if (dmap[y][x]) return;
  pmap[y][x] = 1;
  int tx, ty, i;
  for (i = 0; i < 4; i++) {
    tx = dx[i] + x;
    ty = dy[i] + y;
    if (tx < 0 || tx >= w) continue;
    if (ty < 0 || ty >= h)
      continue;
    else if (dmap[ty][tx] == 2) {
      wmap[y][x] = 1;
    } else if (wmap[ty][tx])
      wmap[y][x] = 1;
    else
      wdfs(ty, tx);
  }
  return;
}
