#include <bits/stdc++.h>
using namespace std;
void spread(int y, int x, vector<vector<bool> >& resField,
            vector<pair<int, int> > enposes);
int main() {
  int w, h;
  while (cin >> w >> h, w || h) {
    vector<vector<bool> > wfield(h, vector<bool>(w, false));
    vector<vector<bool> > bfield(h, vector<bool>(w, false));
    vector<vector<char> > qfield(h, vector<char>(w));
    vector<pair<int, int> > wposes;
    vector<pair<int, int> > bposes;
    for (int y = 0; y < h; ++y)
      for (int x = 0; x < w; ++x) {
        char c;
        cin >> c;
        qfield[y][x] = c;
        if (c == 'W') wposes.push_back(make_pair(y, x));
        if (c == 'B') bposes.push_back(make_pair(y, x));
      }
    for (auto&& wpos : wposes) spread(wpos.first, wpos.second, wfield, bposes);
    for (auto&& bpos : bposes) spread(bpos.first, bpos.second, bfield, wposes);
    int answ, ansb;
    answ = ansb = 0;
    for (int y = 0; y < h; ++y)
      for (int x = 0; x < w; ++x) {
        if (wfield[y][x] xor bfield[y][x] && qfield[y][x] == '.') {
          answ += wfield[y][x];
          ansb += bfield[y][x];
        }
      }
    cout << ansb << ' ' << answ << endl;
  }
  return 0;
}
void spread(int y, int x, vector<vector<bool> >& resField,
            vector<pair<int, int> > enposes) {
  int dy[] = {-1, 0, 1, 0};
  int dx[] = {0, -1, 0, 1};
  int h = resField.size();
  int w = resField[0].size();
  if (y >= 0 && y < h && x >= 0 && x < w && !resField[y][x] &&
      count(begin(enposes), end(enposes), make_pair(y, x)) == 0) {
    resField[y][x] = true;
    for (int i = 0; i < 4; ++i) spread(y + dy[i], x + dx[i], resField, enposes);
  }
}
