#include <bits/stdc++.h>
using namespace std;
int W, H;
vector<string> M;
const vector<int> dx = {0, 1, 0, -1};
const vector<int> dy = {-1, 0, 1, 0};
int rec(int x, int y, vector<vector<bool> > ok) {
  if (M[y][x] == 'W') {
    return 2;
  }
  if (M[y][x] == 'B') {
    return 1;
  }
  int ret = 3;
  for (int dir = 0; dir < 4; dir++) {
    int tx = x + dx[dir];
    int ty = y + dy[dir];
    if (0 <= tx && tx < W && 0 <= ty && ty < H && ok[ty][tx] == false) {
      vector<vector<bool> > ok2 = ok;
      ok2[ty][tx] = true;
      ret = ret & rec(tx, ty, ok2);
    }
  }
  return ret;
}
int main() {
  while (true) {
    cin >> W >> H;
    if (W == 0 && H == 0) {
      break;
    }
    M = vector<string>(H);
    for (int i = 0; i < H; i++) {
      cin >> M[i];
    }
    int b = 0, w = 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (M[i][j] == '.') {
          int c = rec(j, i, vector<vector<bool> >(H, vector<bool>(W, false)));
          if (c == 1) {
            b++;
          }
          if (c == 2) {
            w++;
          }
        }
      }
    }
    cout << b << ' ' << w << endl;
  }
  return 0;
}
