#include <bits/stdc++.h>
using namespace std;
char map[51][51], clr[51][51];
int w, h;
void renew(int x, int y) {
  int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}, newx, newy;
  for (int u = 0; u < 4; u++) {
    newx = x + dx[u], newy = y + dy[u];
    if (newx >= 0 && newx < w && newy >= 0 && newy < h) {
      if (clr[newx][newy] == '.' && map[newx][newy] == '.')
        map[newx][newy] = map[x][y], renew(newx, newy);
      else if (clr[newx][newy] == '.' && map[x][y] != map[newx][newy])
        map[newx][newy] = 'F', renew(newx, newy);
    }
  }
}
int main() {
  while (1) {
    int wcnt = 0, bcnt = 0;
    cin >> w >> h;
    if (w + h == 0) break;
    for (int i = 0; i < w; i++)
      for (int j = 0; j < h; j++) {
        cin >> map[i][j];
        clr[i][j] = map[i][j];
      }
    for (int i = 0; i < w; i++)
      for (int j = 0; j < h; j++) {
        if (clr[i][j] == 'W') wcnt--;
        if (clr[i][j] == 'B') bcnt--;
        if (clr[i][j] != '.') renew(i, j);
      }
    for (int i = 0; i < w; i++)
      for (int j = 0; j < h; j++) {
        if (map[i][j] == 'B')
          bcnt++;
        else if (map[i][j] == 'W')
          wcnt++;
      }
    cout << bcnt << " " << wcnt << endl;
  }
  return 0;
}
