#include <bits/stdc++.h>
using namespace std;
int a[52][52];
int dx[4] = {0, 0, -1, 1};
int dy[4] = {-1, 1, 0, 0};
int cnt[4];
void paint(int y, int x, int color) {
  if (a[y][x] >= 3 || a[y][x] == color) return;
  cnt[a[y][x]]--;
  a[y][x] += color;
  cnt[a[y][x]]++;
  for (int i = 0; i < 4; ++i) paint(y + dy[i], x + dx[i], a[y][x]);
}
int main(void) {
  int h, w;
  char c;
  while (cin >> w >> h, w | h) {
    for (int i = 0; i < 4; ++i) cnt[i] = 0;
    for (int y = 1; y <= h; ++y) {
      for (int x = 1; x <= w; ++x) {
        cin >> c;
        if (c == '.')
          a[y][x] = 0;
        else
          a[y][x] = (c == 'B' ? 10 : 20);
      }
    }
    for (int y = 0; y < h + 2; ++y) a[y][0] = a[y][w + 1] = 30;
    for (int x = 0; x < w + 2; ++x) a[0][x] = a[h + 1][x] = 30;
    for (int y = 1; y <= h; ++y)
      for (int x = 1; x <= w; ++x)
        if (a[y][x] >= 10)
          for (int i = 0; i < 4; ++i) paint(y + dy[i], x + dx[i], a[y][x] / 10);
    cout << cnt[1] << " " << cnt[2] << endl;
  }
  return 0;
}
