#include <bits/stdc++.h>
using namespace std;
char field[52][52];
bool black[52][52];
bool white[52][52];
int t_x[] = {1, 0, -1, 0};
int t_y[] = {0, 1, 0, -1};
void search(int h, int w) {
  char c = field[h][w];
  queue<pair<int, int> > que;
  que.push(pair<int, int>(h, w));
  while (!que.empty()) {
    pair<int, int> n_c = que.front();
    que.pop();
    for (int i = 0; i < 4; i++) {
      int t_h = n_c.first + t_x[i];
      int t_w = n_c.second + t_y[i];
      if (field[t_h][t_w] == '#') continue;
      if (field[t_h][t_w] == c || field[t_h][t_w] == '.') {
        if (c == 'W') {
          if (!white[t_h][t_w]) {
            white[t_h][t_w] = true;
          } else {
            continue;
          }
        }
        if (c == 'B') {
          if (!black[t_h][t_w]) {
            black[t_h][t_w] = true;
          } else {
            continue;
          }
        }
        que.push(pair<int, int>(t_h, t_w));
      }
    }
  }
}
int main() {
  while (true) {
    int width, height;
    cin >> width >> height;
    if (width == 0 && height == 0) break;
    memset(field, '#', sizeof field);
    memset(black, false, sizeof black);
    memset(white, false, sizeof white);
    for (int i = 1; i <= height; i++) {
      for (int j = 1; j <= width; j++) {
        cin >> field[i][j];
      }
    }
    for (int i = 1; i <= height; i++) {
      for (int j = 1; j <= width; j++) {
        if (field[i][j] == 'W' && !white[i][j] ||
            field[i][j] == 'B' && !black[i][j]) {
          search(i, j);
        }
      }
    }
    for (int i = 1; i <= height; i++) {
      for (int j = 1; j <= width; j++) {
      }
    }
    for (int i = 1; i <= height; i++) {
      for (int j = 1; j <= width; j++) {
      }
    }
    int b_counter = 0, w_counter = 0;
    for (int i = 1; i <= height; i++) {
      for (int j = 1; j <= width; j++) {
        if (field[i][j] != '.') continue;
        if (!black[i][j] && white[i][j]) w_counter++;
        if (black[i][j] && !white[i][j]) b_counter++;
      }
    }
    cout << b_counter << " " << w_counter << endl;
  }
  return 0;
}
