#include <bits/stdc++.h>
using namespace std;
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
int w, h;
int a[50][50];
void print() {
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      printf("%3d", a[i][j]);
    }
    puts("");
  }
}
bool solve(int x, int y, int c) {
  if (!(0 <= x && x < h && 0 <= y && y < w)) return true;
  if (a[x][y] == c || a[x][y] == c * 2) return true;
  if (a[x][y] != 0) return false;
  bool flag = true;
  a[x][y] = c * 2;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (!solve(nx, ny, c)) {
      flag = false;
      break;
    }
  }
  if (!flag) {
    a[x][y] = 10;
    return false;
  } else
    return true;
}
int main() {
  while (cin >> w >> h, !(w == 0 && h == 0)) {
    memset(a, 0, sizeof(a));
    for (int i = 0; i < h; i++) {
      string s;
      cin >> s;
      for (int j = 0; j < w; j++) {
        if (s[j] == 'W')
          a[i][j] = 1;
        else if (s[j] == 'B')
          a[i][j] = -1;
        else if (s[j] == '.')
          a[i][j] == 0;
      }
    }
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++) {
        if (a[i][j] == 1)
          for (int k = 0; k < 4; k++) solve(i + dx[k], j + dy[k], 1);
        else if (a[i][j] == -1)
          for (int k = 0; k < 4; k++) solve(i + dx[k], j + dy[k], -1);
      }
    int wcnt = 0, bcnt = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (a[i][j] == 2) wcnt++;
        if (a[i][j] == -2) bcnt++;
      }
    }
    cout << bcnt << " " << wcnt << endl;
  }
  return 0;
}
