#include <bits/stdc++.h>
using namespace std;
int map[50][50];
int zyo[50][50];
int w, h;
int flag;
void solve(int H, int W) {
  int dx[4] = {-1, 1, 0, 0};
  int dy[4] = {0, 0, 1, -1};
  for (int a = 0; a < 4; a++) {
    if (H + dx[a] < 0 || H + dx[a] >= h) continue;
    if (W + dy[a] < 0 || W + dy[a] >= w) continue;
    if (zyo[H + dx[a]][W + dy[a]] == -1 && map[H + dx[a]][W + dy[a]] == 0) {
      zyo[H + dx[a]][W + dy[a]] = 3;
      solve(H + dx[a], W + dy[a]);
    } else if (map[H + dx[a]][W + dy[a]] == 1) {
      if (flag == -1) flag = 1;
      if (flag == 2) flag = 0;
    } else if (map[H + dx[a]][W + dy[a]] == 2) {
      if (flag == -1) flag = 2;
      if (flag == 1) flag = 0;
    }
  }
  return;
}
int main(void) {
  char tmp;
  int bc, wc;
  while (1) {
    memset(map, -1, sizeof(map));
    memset(zyo, -1, sizeof(zyo));
    bc = 0, wc = 0;
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> tmp;
        switch (tmp) {
          case '.':
            map[i][j] = 0;
            zyo[i][j] = -1;
            break;
          case 'B':
            map[i][j] = 1;
            zyo[i][j] = 0;
            break;
          case 'W':
            map[i][j] = 2;
            zyo[i][j] = 0;
            break;
        }
      }
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (zyo[i][j] == -1) {
          zyo[i][j] = 3;
          flag = -1;
          solve(i, j);
          for (int k = 0; k < h; k++) {
            for (int l = 0; l < w; l++) {
              if (zyo[k][l] == 3) zyo[k][l] = flag;
            }
          }
        }
      }
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (zyo[i][j] == 1)
          bc++;
        else if (zyo[i][j] == 2)
          wc++;
      }
    }
    cout << bc << " " << wc << endl;
  }
  return 0;
}
