#include <bits/stdc++.h>
using namespace std;
int h, w;
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};
char mp[55][55];
int B = 0, W = 0;
int dfs(int y, int x, int num, int sum, bool& white, bool& black) {
  mp[y][x] = num;
  int cnt = 0;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (mp[ny][nx] == 'B') {
      black = true;
    }
    if (mp[ny][nx] == 'W') {
      white = true;
    }
    if (0 <= nx && nx < w && 0 <= ny && ny < h && mp[ny][nx] == '.') {
      cnt += dfs(ny, nx, num, sum, white, black);
      cnt++;
    }
  }
  return cnt;
}
int solve() {
  int res = '0';
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      if (mp[y][x] == '.') {
        bool white = false, black = false;
        int sum = dfs(y, x, res, 1, white, black) + 1;
        res++;
        if (black == true && white == false) {
          B += sum;
        } else if (black == false && white == true) {
          W += sum;
        }
      }
    }
  }
  return res;
}
int main() {
  while (cin >> w >> h, h) {
    for (int i = 0; i < 55; i++) {
      for (int j = 0; j < 55; j++) {
        mp[i][j] = '&';
      }
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> mp[i][j];
      }
    }
    solve();
    cout << B << " " << W << endl;
    B = W = 0;
  }
  return 0;
}
