#include <bits/stdc++.h>
using namespace std;
int w, h;
char tbl[60][60];
bool f[2][60][60];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
void dfs(int x, int y, int c) {
  f[c][y][x] = true;
  for (int i = 0; i < 4; ++i) {
    int mx = x + dx[i];
    int my = y + dy[i];
    if (mx < 0 || my < 0) continue;
    if (mx >= w || my >= h) continue;
    if (f[c][my][mx]) continue;
    if (tbl[my][mx] != '.') continue;
    dfs(mx, my, c);
  }
}
int main() {
  while (cin >> w >> h, w || h) {
    memset(f, 0, sizeof(f));
    for (int i = 0; i < h; ++i) cin >> tbl[i];
    for (int i = 0; i < h; ++i)
      for (int j = 0; j < w; ++j) {
        if (tbl[i][j] == 'B') {
          dfs(j, i, 0);
        }
        if (tbl[i][j] == 'W') {
          dfs(j, i, 1);
        }
      }
    int B = 0, W = 0;
    for (int i = 0; i < h; ++i)
      for (int j = 0; j < w; ++j) {
        if (tbl[i][j] == '.' && f[0][i][j] && !f[1][i][j]) ++B;
        if (tbl[i][j] == '.' && f[1][i][j] && !f[0][i][j]) ++W;
      }
    cout << B << " " << W << endl;
  }
  return 0;
}
