#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)

int w,h;
bool black[51][51];
bool white[51][51];
string field[51];

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(int x, int y, char c) {
  if ((c == 'B' and black[y][x]) || (c == 'W' and white[y][x])) return;

  if (c == 'W' and field[y][x] != 'W') white[y][x] = true;
  else if (c == 'B' and field[y][x] != 'B') black[y][x] = true;

  rep(i, 4) {
    int nx = x + dx[i], ny = y + dy[i];
    if (0 <= nx and nx < w and 0 <= ny and ny < h and field[ny][nx] == '.') {
      solve(nx, ny, c);
    }
  }
}

int main() {
  while (cin >> w >> h, w || h) {
    rep(i, h) {
      cin >> field[i];
    }

    fill(black[0], black[50], false);
    fill(white[0], white[50], false);

    rep(i, h) rep(j, w) {
      if (field[i][j] == 'W') solve(j,i,'W');
      else if (field[i][j] == 'B') solve(j,i,'B');
    }

    int bl, wh;
    bl = wh = 0;

    rep(i, h) rep(j, w) {
      if (black[i][j] && !white[i][j]) bl += 1;
      else if (!black[i][j] && white[i][j]) wh += 1;
    }

    cout << bl << " " << wh << endl;
  }
}
