#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int w, h;
vector<string> ss;
bool is_white[103][103];
bool is_black[103][103];
void dfs(int x_, int y_, bool (*f_)[103], bool f2) {
  if (f_[x_][y_] || (ss[x_][y_] != '.' && f2)) return;
  f_[x_][y_] = true;
  for (int i = 0; i < (4); i++) {
    int x = x_ + dx[i];
    int y = y_ + dy[i];
    if (0 <= x && x < ss.size() && 0 <= y && y < ss[x].size()) {
      dfs(x, y, f_, true);
    }
  }
}
void solve() {
  for (int i = 0; i < (103); i++)
    for (int j = 0; j < (103); j++) is_white[i][j] = is_black[i][j] = false;
  ss.resize(w);
  for (int i = 0; i < (h); i++) {
    string t;
    cin >> t;
    ss[i] = t;
  }
  int ans_b = 0, ans_w = 0;
  for (int i = 0; i < (ss.size()); i++) {
    for (int j = 0; j < (ss[i].size()); j++) {
      if (ss[i][j] == 'B') dfs(i, j, is_black, false);
      if (ss[i][j] == 'W') dfs(i, j, is_white, false);
    }
  }
  for (int i = 0; i < (ss.size()); i++)
    for (int j = 0; j < (ss[i].size()); j++) {
      if (ss[i][j] == '.' && (is_white[i][j] ^ is_black[i][j])) {
        if (is_white[i][j])
          ans_w++;
        else
          ans_b++;
      }
    }
  cout << ans_b << " " << ans_w << endl;
  ss.clear();
}
int main() {
  while (cin >> w >> h) {
    if (w + h == 0) return 0;
    solve();
  }
  return 0;
}
