#include <bits/stdc++.h>
using namespace std;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, 1, 0, -1};
int w, h, cntw, cntb;
bool used[2][50][50];
char mas[50][50];
void dfs(int y, int x, bool wb) {
  if (mas[y][x] != '.' || used[wb][y][x]++) return;
  for (int i = 0; i < 4; i++) dfs(y + dy[i], x + dx[i], wb);
}
int main() {
  while (cin >> w >> h, w) {
    fill_n(**used, 5000, 0);
    cntw = cntb = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) cin >> mas[i][j];
    }
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++) {
        if (mas[i][j] == 'W')
          for (int k = 0; k < 4; k++) dfs(i + dy[k], j + dx[k], 1);
        if (mas[i][j] == 'B')
          for (int k = 0; k < 4; k++) dfs(i + dy[k], j + dx[k], 0);
      }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (used[0][i][j] && !used[1][i][j])
          cntw++;
        else if (!used[0][i][j] && used[1][i][j])
          cntb++;
      }
    }
    cout << cntw << " " << cntb << endl;
  }
}
