#include <bits/stdc++.h>
using namespace std;
int vis[60][60];
string map[51];
int w, h;
void emp() {
  int i, j;
  for (i = 0; i < 60; i++) {
    for (j = 0; j < 60; j++) {
      vis[i][j] = 0;
    }
  }
}
void dfsw(int i, int j) {
  vis[i][j] += 3;
  if (j + 1 < w && (vis[i][j + 1] == 0 || vis[i][j + 1] == 4)) dfsw(i, j + 1);
  if (0 <= i - 1 && (vis[i - 1][j] == 0 || vis[i - 1][j] == 4)) dfsw(i - 1, j);
  if (0 <= j - 1 && (vis[i][j - 1] == 0 || vis[i][j - 1] == 4)) dfsw(i, j - 1);
  if (i + 1 < h && (vis[i + 1][j] == 0 || vis[i + 1][j] == 4)) dfsw(i + 1, j);
}
void dfsb(int i, int j) {
  vis[i][j] += 4;
  if (j + 1 < w && (vis[i][j + 1] == 0 || vis[i][j + 1] == 3)) dfsb(i, j + 1);
  if (0 <= i - 1 && (vis[i - 1][j] == 0 || vis[i - 1][j] == 3)) dfsb(i - 1, j);
  if (0 <= j - 1 && (vis[i][j - 1] == 0 || vis[i][j - 1] == 3)) dfsb(i, j - 1);
  if (i + 1 < h && (vis[i + 1][j] == 0 || vis[i + 1][j] == 3)) dfsb(i + 1, j);
}
int main() {
  int i, j;
  int bc, wc;
  while (1) {
    emp();
    bc = 0;
    wc = 0;
    scanf("%d%d", &w, &h);
    if (w == 0 && h == 0) break;
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
        cin >> map[i][j];
        if (map[i][j] == 'W') {
          vis[i][j] = 2;
        } else if (map[i][j] == 'B') {
          vis[i][j] = 1;
        } else if (map[i][j] == '.') {
          vis[i][j] = 0;
        }
      }
    }
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
        if (vis[i][j] == 1) dfsb(i, j);
        if (vis[i][j] == 2) dfsw(i, j);
      }
    }
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
        if (vis[i][j] == 4) bc++;
        if (vis[i][j] == 3) wc++;
      }
    }
    printf("%d %d\n", bc, wc);
  }
  return 0;
}
