#include <bits/stdc++.h>
using namespace std;
char map[50][50];
bool memoB[50][50];
bool memoW[50][50];
void search(int x, int y, int w, int h, char color) {
  if (color == 'B') {
    memoB[x][y] = true;
  } else {
    memoW[x][y] = true;
  }
  if (x > 0 && map[x - 1][y] == '.') {
    if ((color == 'B' && !memoB[x - 1][y]) ||
        (color == 'W' && !memoW[x - 1][y])) {
      search(x - 1, y, w, h, color);
    }
  }
  if (y > 0 && map[x][y - 1] == '.') {
    if ((color == 'B' && !memoB[x][y - 1]) ||
        (color == 'W' && !memoW[x][y - 1])) {
      search(x, y - 1, w, h, color);
    }
  }
  if (x < w - 1 && map[x + 1][y] == '.') {
    if ((color == 'B' && !memoB[x + 1][y]) ||
        (color == 'W' && !memoW[x + 1][y])) {
      search(x + 1, y, w, h, color);
    }
  }
  if (y < h - 1 && map[x][y + 1] == '.') {
    if ((color == 'B' && !memoB[x][y + 1]) ||
        (color == 'W' && !memoW[x][y + 1])) {
      search(x, y + 1, w, h, color);
    }
  }
}
int main() {
  int w, h, cntB, cntW, resB, resW;
  char tmp;
  while (cin >> w >> h, w | h) {
    cntB = cntW = 0;
    for (int i = 0; i < w; i++) {
      for (int j = 0; j < h; j++) {
        cin >> tmp;
        map[i][j] = tmp;
        if (tmp == '.') memoB[i][j] = false;
        memoW[i][j] = false;
        if (tmp == 'B') memoB[i][j] = true, memoW[i][j] = false, cntB++;
        if (tmp == 'W') memoB[i][j] = false, memoW[i][j] = true, cntW++;
      }
    }
    for (int i = 0; i < w; i++) {
      for (int j = 0; j < h; j++) {
        if (map[i][j] == 'B') search(i, j, w, h, 'B');
        if (map[i][j] == 'W') search(i, j, w, h, 'W');
      }
    }
    resB = 0;
    resW = 0;
    for (int i = 0; i < w; i++) {
      for (int j = 0; j < h; j++) {
        if (memoB[i][j] && !memoW[i][j]) resB++;
        if (!memoB[i][j] && memoW[i][j]) resW++;
      }
    }
    cout << resB - cntB << " " << resW - cntW << endl;
  }
}
