#include <bits/stdc++.h>
using namespace std;
int f[50][50];
int dfs(vector<vector<int>> &m, int h, int w, vector<vector<char>> as) {
  if (h < 0 || w < 0 || h >= m.size() || w >= m[h].size()) {
    return 0;
  }
  if (as[h][w] == 'B') return 1;
  if (as[h][w] == 'W') return 2;
  if (f[h][w]) return 0;
  f[h][w] = 1;
  int t = 0;
  t |= dfs(m, h - 1, w, as);
  t |= dfs(m, h + 1, w, as);
  t |= dfs(m, h, w + 1, as);
  t |= dfs(m, h, w - 1, as);
  return t;
}
int main() {
  int w, h;
  while (cin >> w >> h, w) {
    for (int i = 0; i < 50; i++)
      for (int j = 0; j < 50; j++) f[i][j] = 0;
    vector<vector<char>> as;
    as.resize(h);
    for (int i = 0; i < h; i++) {
      string s;
      cin >> s;
      for (char c : s) as[i].push_back(c);
    }
    vector<vector<int>> mat(h, vector<int>(w, 0));
    dfs(mat, 9, 9, as);
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (as[i][j] == '.') {
          mat[i][j] = dfs(mat, i, j, as);
          for (int i = 0; i < 50; i++)
            for (int j = 0; j < 50; j++) f[i][j] = 0;
        }
      }
    }
    int ans_w = 0, ans_b = 0;
    for (auto mm : mat) {
      for (auto m : mm) {
        if (m == 1) ans_b++;
        if (m == 2) ans_w++;
      }
    }
    cout << ans_b << ' ' << ans_w << endl;
  }
}
