#include <bits/stdc++.h>
using namespace std;
int main() {
  int W, H;
  while (1) {
    cin >> W >> H;
    if (W == 0 && H == 0) break;
    int n[53][53] = {};
    int c = 0;
    string str;
    for (int i = 1; i < H + 1; i++) {
      cin >> str;
      c++;
      for (int j = 1; j < W + 1; j++) {
        if (str[j - 1] == '.') {
          n[i][j] = c;
        }
        if (str[j - 1] == 'W') {
          n[i][j] = 7001;
          c++;
        }
        if (str[j - 1] == 'B') {
          n[i][j] = 7002;
          c++;
        }
      }
    }
    for (int i = 1; i <= H; i++)
      for (int j = 1; j <= W; j++) {
        if (n[i][j] < 7000) {
          int g[] = {n[i - 1][j], n[i + 1][j], n[i][j - 1], n[i][j + 1]};
          int Q = n[i][j];
          if (n[i - 1][j] > 0 && n[i - 1][j] < Q) Q = n[i - 1][j];
          if (n[i + 1][j] > 0 && n[i + 1][j] < Q) Q = n[i + 1][j];
          if (n[i][j - 1] > 0 && n[i][j - 1] < Q) Q = n[i][j - 1];
          if (n[i][j + 1] > 0 && n[i][j + 1] < Q) Q = n[i][j + 1];
          for (int I = 1; I <= H; I++)
            for (int J = 1; J <= W; J++)
              for (int K = 0; K <= 4; K++)
                if (n[I][J] == g[K] && g[K] < 7000) n[I][J] = Q;
        }
      }
    int map[7000] = {};
    for (int i = 1; i <= H; i++)
      for (int j = 1; j <= W; j++) {
        if (n[i][j] == 7001) {
          int G[] = {n[i - 1][j], n[i + 1][j], n[i][j - 1], n[i][j + 1]};
          for (int k = 0; k < 4; k++)
            if (map[G[k]] == 0 || map[G[k]] == 2) map[G[k]] += 1;
        }
        if (n[i][j] == 7002) {
          int G[] = {n[i - 1][j], n[i + 1][j], n[i][j - 1], n[i][j + 1]};
          for (int k = 0; k < 4; k++)
            if (map[G[k]] == 0 || map[G[k]] == 1) map[G[k]] += 2;
        }
      }
    int cnt[5540] = {};
    for (int i = 1; i <= H; i++)
      for (int j = 1; j <= W; j++) cnt[n[i][j]]++;
    int J = 0, JJ = 0;
    for (int i = 1; i < 5500; i++) {
      if (map[i] == 1)
        JJ += cnt[i];
      else if (map[i] == 2)
        J += cnt[i];
    }
    cout << J << " " << JJ << endl;
  }
  return 0;
}
