#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
char A[50][50];
bool isB[50][50];
bool isW[50][50];
int main() {
  int w, h;
  deque<P> B, W;
  while (cin >> w >> h, w) {
    B.clear();
    W.clear();
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> A[i][j];
        if (A[i][j] == 'B') B.emplace_back(i, j);
        if (A[i][j] == 'W') W.emplace_back(i, j);
      }
    }
    fill(isB[0], isB[50], false);
    fill(isW[0], isW[50], false);
    while (!B.empty()) {
      int y, x;
      tie(y, x) = B.front();
      B.pop_front();
      isB[y][x] = true;
      int d[5] = {0, 1, 0, -1, 0};
      for (int i = 0; i < 4; i++) {
        int yy = y + d[i], xx = x + d[i + 1];
        if (yy < 0 || yy >= h || xx < 0 || xx >= w) continue;
        if (!isB[yy][xx] && A[yy][xx] == '.') {
          B.emplace_back(yy, xx);
        }
      }
    }
    while (!W.empty()) {
      int y, x;
      tie(y, x) = W.front();
      W.pop_front();
      isW[y][x] = true;
      int d[5] = {0, 1, 0, -1, 0};
      for (int i = 0; i < 4; i++) {
        int yy = y + d[i], xx = x + d[i + 1];
        if (yy < 0 || yy >= h || xx < 0 || xx >= w) continue;
        if (!isW[yy][xx] && A[yy][xx] == '.') {
          W.emplace_back(yy, xx);
        }
      }
    }
    int ansB = 0, ansW = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (A[i][j] == '.' && isB[i][j] && !isW[i][j]) ansB++;
        if (A[i][j] == '.' && !isB[i][j] && isW[i][j]) ansW++;
      }
    }
    cout << ansB << ' ' << ansW << endl;
  }
  return 0;
}
