#include <bits/stdc++.h>
using namespace std;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
char a[64][64];
int w, h;
queue<int> X, Y;
int main(void) {
  while (1) {
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> a[i][j];
      }
    }
    int white = 0, black = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (a[i][j] != '.') continue;
        bool used[64][64];
        for (int k = 0; k < h; k++) {
          for (int l = 0; l < w; l++) {
            used[k][l] = false;
          }
        }
        X.push(j);
        Y.push(i);
        bool white_flag = false, black_flag = false;
        while (!X.empty()) {
          int x = X.front();
          X.pop();
          int y = Y.front();
          Y.pop();
          used[y][x] = true;
          for (int k = 0; k < 4; k++) {
            int nx = x + dx[k];
            int ny = y + dy[k];
            if (0 <= nx && nx < w && 0 <= ny && ny < h) {
              if (a[ny][nx] == 'W')
                white_flag = true;
              else if (a[ny][nx] == 'B')
                black_flag = true;
              else if (!used[ny][nx]) {
                X.push(nx);
                Y.push(ny);
              }
            }
          }
        }
        if (white_flag && !black_flag) white++;
        if (!white_flag && black_flag) black++;
      }
    }
    cout << black << " " << white << endl;
  }
  return 0;
}
