#include <bits/stdc++.h>
using namespace std;
int w, h;
char brd[51][51];
bool done[51][51];
bool calc_done[51][51];
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
int only(int y, int x) {
  if (!(0 <= y && y < h)) return 0;
  if (!(0 <= x && x < w)) return 0;
  if (done[y][x]) return 0;
  done[y][x] = true;
  if (brd[y][x] == 'B')
    return 1;
  else if (brd[y][x] == 'W')
    return 2;
  int code = 0;
  if (brd[y][x] == '.') {
    for (int i = (0); i < (4); i++) code |= only(y + dy[i], x + dx[i]);
  }
  return code;
}
int calc(int y, int x) {
  if (!(0 <= y && y < h)) return 0;
  if (!(0 <= x && x < w)) return 0;
  if (calc_done[y][x]) return 0;
  calc_done[y][x] = true;
  if (brd[y][x] != '.') return 0;
  int cnt = 1;
  for (int i = (0); i < (4); i++) cnt += calc(y + dy[i], x + dx[i]);
  return cnt;
}
int main(void) {
  while (cin >> h >> w, w | h) {
    for (int j = (0); j < (h); j++)
      for (int i = (0); i < (w); i++) cin >> brd[j][i];
    int ww, bb;
    ww = bb = 0;
    memset(calc_done, 0, sizeof(calc_done));
    for (int j = (0); j < (h); j++) {
      for (int i = (0); i < (w); i++) {
        memset(done, 0, sizeof(done));
        int c = only(j, i);
        if ((c & 1) && (c & 2))
          continue;
        else if (c & 1)
          bb += calc(j, i);
        else if (c & 2)
          ww += calc(j, i);
      }
    }
    printf("%d %d\n", bb, ww);
  }
  return 0;
}
