#include <bits/stdc++.h>
using namespace std;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int w, h;
char fie[51][51];
void dfs(int x, int y) {
  for (int i = 0; i < 4; i++) {
    int xx = x + dx[i];
    int yy = y + dy[i];
    if (0 <= xx && xx <= w && 0 <= yy && yy <= h && fie[yy][xx] == '.') {
      fie[yy][xx] = 'w';
      dfs(xx, yy);
    }
  }
}
void dfs2(int x, int y) {
  for (int i = 0; i < 4; i++) {
    int xx = x + dx[i];
    int yy = y + dy[i];
    if (0 <= xx && xx <= w && 0 <= yy && yy <= h &&
        (fie[yy][xx] == '.' || fie[yy][xx] == 'w')) {
      if (fie[yy][xx] == '.') {
        fie[yy][xx] = 'b';
      } else if (fie[yy][xx] == 'w') {
        fie[yy][xx] = 'x';
      }
      dfs2(xx, yy);
    }
  }
}
int main() {
  while (cin >> w >> h, w || h) {
    for (int i = 0; i < h; i++) {
      cin >> fie[i];
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (fie[i][j] == 'W') dfs(j, i);
      }
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (fie[i][j] == 'B') dfs2(j, i);
      }
    }
    int answ = 0, ansb = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (fie[i][j] == 'w') answ++;
        if (fie[i][j] == 'b') ansb++;
      }
    }
    cout << ansb << " " << answ << endl;
  }
}
