#include <bits/stdc++.h>
using namespace std;
char d[50][60];
bool w[50][50];
bool b[50][50];
int ww, hh;
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
void dfsw(int y, int x) {
  w[y][x] == true;
  for (int i = 0; i < (4); i++) {
    int xx = x + dx[i];
    int yy = y + dy[i];
    if (xx < 0 || yy < 0) continue;
    if (xx >= ww || yy >= hh) continue;
    if (d[yy][xx] != 'B' && !w[yy][xx]) {
      w[yy][xx] = true;
      dfsw(yy, xx);
    }
  }
}
void dfsb(int y, int x) {
  b[y][x] == true;
  for (int i = 0; i < (4); i++) {
    int xx = x + dx[i];
    int yy = y + dy[i];
    if (xx < 0 || yy < 0) continue;
    if (xx >= ww || yy >= hh) continue;
    if (d[yy][xx] != 'W' && !b[yy][xx]) {
      b[yy][xx] = true;
      dfsb(yy, xx);
    }
  }
}
int main() {
  while (scanf("%d%d", &ww, &hh), ww + hh) {
    memset(w, 0, sizeof(w));
    memset(b, 0, sizeof(b));
    for (int i = 0; i < (hh); i++) scanf("%s", d[i]);
    for (int i = 0; i < (hh); i++)
      for (int j = 0; j < (ww); j++) {
        if (d[i][j] == 'W' && !w[i][j]) dfsw(i, j);
        if (d[i][j] == 'B' && !b[i][j]) dfsb(i, j);
      }
    int a1 = 0, a2 = 0;
    for (int i = 0; i < (hh); i++)
      for (int j = 0; j < (ww); j++) {
        if (d[i][j] == '.' && w[i][j] && !b[i][j]) a2++;
        if (d[i][j] == '.' && !w[i][j] && b[i][j]) a1++;
      }
    printf("%d %d\n", a1, a2);
  }
}
