#include <bits/stdc++.h>
using namespace std;
int a[51][51], w, h, c;
bool f;
void visit(int i, int j, int bw) {
  a[i][j] = 3;
  c++;
  int di[4] = {1, 0, -1, 0};
  int dj[4] = {0, 1, 0, -1};
  for (int t = 0; t < 4; t++) {
    int vi = i + di[t];
    int vj = j + dj[t];
    if (bw == 1) {
      if (a[vi][vj] == 2) {
        f = false;
      } else if (vi >= 0 && vj >= 0 && vi < w && vj < h && !a[vi][vj]) {
        visit(vi, vj, 1);
      }
    } else if (bw == 2) {
      if (a[vi][vj] == 1) {
        f = false;
      } else if (vi >= 0 && vj >= 0 && vi < w && vj < h && !a[vi][vj]) {
        visit(vi, vj, 2);
      }
    }
  }
}
int main() {
  int i, j, b, wh;
  char str;
  while (1) {
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    for (i = 0; i <= h; i++) {
      for (j = 0; j <= w; j++) {
        if (i == h || j == w)
          a[j][i] = 3;
        else {
          cin >> str;
          if (str == 'B')
            a[j][i] = 1;
          else if (str == 'W')
            a[j][i] = 2;
          else
            a[j][i] = 0;
        }
      }
    }
    b = wh = 0;
    int di[4] = {1, 0, -1, 0};
    int dj[4] = {0, 1, 0, -1};
    for (j = 0; j < h; j++) {
      for (i = 0; i < w; i++) {
        if (a[i][j] == 1 || a[i][j] == 2) {
          for (int t = 0; t < 4; t++) {
            int vi = i + di[t];
            int vj = j + dj[t];
            if (a[i][j] == 1 && vi >= 0 && vj >= 0 && vi < w && vj < h &&
                !a[vi][vj]) {
              c = 0;
              f = true;
              visit(vi, vj, 1);
              if (f) b += c;
            } else if (a[i][j] == 2 && vi >= 0 && vj >= 0 && vi < w && vj < h &&
                       !a[vi][vj]) {
              c = 0;
              f = true;
              visit(vi, vj, 2);
              if (f) wh += c;
            }
          }
        }
      }
    }
    cout << b << " " << wh << endl;
  }
  return 0;
}
