#include <bits/stdc++.h>
using namespace std;
enum { NONE, BLA, WHI };
int kui[50][50] = {};
bool rin[50][50][2] = {};
int W, H;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
void clear() {
  for (int i = 0; i < 50; i++) {
    for (int j = 0; j < 50; j++) {
      kui[i][j] = 0;
      rin[i][j][0] = false;
      rin[i][j][1] = false;
    }
  }
}
void rec(int x, int y, int color) {
  if (x >= W || x < 0 || y >= H || y < 0) return;
  if (kui[x][y] || rin[x][y][color]) return;
  rin[x][y][color] = true;
  for (int i = 0; i < 4; i++) {
    rec(x + dx[i], y + dy[i], color);
  }
}
int main() {
  while (cin >> W >> H, W || H) {
    for (int i = 0; i < W; i++) {
      for (int j = 0; j < H; j++) {
        char t;
        cin >> t;
        switch (t) {
          case '.':
            break;
          case 'B':
            kui[i][j] = BLA;
            break;
          case 'W':
            kui[i][j] = WHI;
            break;
        }
      }
    }
    for (int i = 0; i < W; i++) {
      for (int j = 0; j < H; j++) {
        switch (kui[i][j]) {
          case BLA:
            for (int k = 0; k < 4; k++) rec(i + dx[k], j + dy[k], BLA);
            break;
          case WHI:
            for (int k = 0; k < 4; k++) rec(i + dx[k], j + dy[k], WHI);
            break;
        }
      }
    }
    int sumw = 0, sumb = 0;
    for (int i = 0; i < W; i++) {
      for (int j = 0; j < H; j++) {
        if (rin[i][j][BLA] && (!rin[i][j][WHI])) sumb++;
        if (rin[i][j][WHI] && (!rin[i][j][BLA])) sumw++;
      }
    }
    cout << sumb << " " << sumw << endl;
    clear();
  }
}
