#include <iostream>
using namespace std;
int w, h;
char data[50][50];
int cnt;
char bw;
bool flag;
 
void rec(int x, int y) {
  static int d[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};
  data[y][x] = '#';
  cnt++;
  for(int i = 0; i < 4; i++) {
    int nx = x + d[i][0];
    int ny = y + d[i][1];
    if(nx < 0 || nx >= w) continue;
    if(ny < 0 || ny >= h) continue;
    if(data[ny][nx] == '#') continue;
    if(data[ny][nx] != '.') {
      if(bw == '.') bw = data[ny][nx];
      else if(data[ny][nx] != bw) flag = false;
      continue;
    }
    rec(nx, ny);
  }
}
 
int main() {
  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        cin >> data[i][j];
      }
    }
    int numW = 0;
    int numB = 0;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        if(data[i][j] == '.') {
          cnt = 0;
          bw = '.';
          flag = true;
          rec(j, i);
          if(flag) {
            if(bw == 'B') numB += cnt;
            else if(bw == 'W') numW += cnt;
          }
        }
      }
    }
    cout << numB << ' ' << numW << endl;
  }
  return 0;
}