#include <bits/stdc++.h>
int di[4] = {1, 0, -1, 0};
int dj[4] = {0, 1, 0, -1};
using namespace std;
const long long INF = 1e18;
int w, h;
char field[50][50];
bool visited[50][50];
bool white_flg;
bool black_flg;
int dfs(int i, int j) {
  if (i < 0 || h <= i || j < 0 || j >= w || visited[i][j]) return 0;
  if (field[i][j] == 'B') {
    black_flg = true;
    return 0;
  }
  if (field[i][j] == 'W') {
    white_flg = true;
    return 0;
  }
  visited[i][j] = true;
  int res = 1;
  for (int k = 0; k < (4); k++) {
    res += dfs(i + di[k], j + dj[k]);
  }
  return res;
}
int main() {
  while (cin >> w >> h) {
    if (w + h == 0) break;
    int white = 0;
    int black = 0;
    memset(visited, false, sizeof(visited));
    for (int i = 0; i < (h); i++) cin >> field[i];
    for (int i = 0; i < (h); i++) {
      for (int j = 0; j < (w); j++) {
        if (!visited[i][j] && field[i][j] == '.') {
          white_flg = false;
          black_flg = false;
          int s = dfs(i, j);
          if (white_flg && !black_flg)
            white += s;
          else if (black_flg && !white_flg)
            black += s;
        }
      }
    }
    cout << black << ' ' << white << endl;
  }
  return 0;
}
