/**
 *  Surrounding Area (Problem C, Practice Contest for Japan Domestic, 2007-06-24)
 *  by Kenji Inoue, 2007-06-25
 **/

#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<string> f;

int DX[] = {-1, 1, 0,  0};
int DY[] = { 0, 0, 1, -1};
int w, h;

void rec(int x, int y, char c) {
  for (int d=0; d<4; d++) {
    int mx = x + DX[d], my = y + DY[d];
    if (my < 0 || h <= my || mx < 0 || w <= mx) { continue; }

    if (f[my][mx] == '.') {
      f[my][mx] = (c == 'B' ? 'b' : 'w');
      rec(mx, my, c);
    } else if (    (f[my][mx] == 'b' && c == 'W')
                || (f[my][mx] == 'w' && c == 'B')) {
      // only black/white -> both
      f[my][mx] = 'o';
      rec(mx, my, c);
    }
  }
}

int main() {
  while (cin >> w >> h, (w||h)) {
    f.clear();
    for (int y=0; y<h; y++) {
      string s;
      cin >> s;
      f.push_back(s);
    }

    for (int y=0; y<h; y++) {
      for (int x=0; x<w; x++) {
        if (f[y][x] == 'W' || f[y][x] == 'B') {
          rec(x, y, f[y][x]);
        }
      }
    }

    int blacks = 0, whites = 0;
    for (int y=0; y<h; y++) {
      for (int x=0; x<w; x++) {
        if (f[y][x] == 'b') {
          blacks++;
        } else if (f[y][x] == 'w') {
          whites++;
        }
      }
    }

    cout << blacks << " " << whites << endl;
  }

  return 0;
}
