#include <bits/stdc++.h>
using namespace std;
int h, w;
int black[52][52];
int white[52][52];
bool chk_b(int x, int y) {
  if (black[x][y] == 1) return true;
  if (black[x][y] < 0) return false;
  if (black[x][y] == 0) {
    black[x][y] = -1;
    if (chk_b(x - 1, y) || chk_b(x + 1, y) || chk_b(x, y + 1) ||
        chk_b(x, y - 1)) {
      black[x][y] = 1;
      return true;
    } else {
      black[x][y] = 0;
      return false;
    }
  }
}
bool chk_w(int x, int y) {
  if (white[x][y] == 1) return true;
  if (white[x][y] < 0) return false;
  if (white[x][y] == 0) {
    white[x][y] = -1;
    if (chk_w(x - 1, y) || chk_w(x + 1, y) || chk_w(x, y + 1) ||
        chk_w(x, y - 1)) {
      white[x][y] = 1;
      return true;
    } else {
      white[x][y] = 0;
      return false;
    }
  }
}
int reset() {
  for (int y = 1; y < 51; y++) {
    for (int x = 1; x < 51; x++) {
      black[x][y] = 0;
      white[x][y] = 0;
    }
  }
  for (int i = 0; i < 52; i++) {
    black[i][0] = -2;
    black[0][i] = -2;
    black[i][h + 1] = -2;
    black[w + 1][i] = -2;
    white[i][0] = -2;
    white[0][i] = -2;
    white[i][h + 1] = -2;
    white[w + 1][i] = -2;
  }
}
int main() {
  while (true) {
    int bb = 0, ww = 0;
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    reset();
    vector<string> dataset(h);
    for (int i = 0; i < h; i++) {
      cin >> dataset[i];
    }
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        switch (dataset[y][x]) {
          case '.':
            break;
          case 'W':
            white[x + 1][y + 1] = 1;
            black[x + 1][y + 1] = -1;
            ww--;
            break;
          case 'B':
            bb--;
            black[x + 1][y + 1] = 1;
            white[x + 1][y + 1] = -1;
            break;
        }
      }
    }
    for (int y = 1; y < h + 1; y++) {
      for (int x = 1; x < w + 1; x++) {
        if (chk_b(x, y) && !chk_w(x, y)) bb++;
        if (!chk_b(x, y) && chk_w(x, y)) ww++;
      }
    }
    cout << bb << " " << ww << endl;
  }
  return 0;
}
