#include <bits/stdc++.h>

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9

using namespace std;

int m[50][50];
int w, h;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void dfs(int cw, int ch, int kind){
  REP(i, 4){
    int nw = cw + dx[i]; int nh = ch + dy[i];
    if(0 <= nw and nw < w and 0 <= nh and nh < h){
      if(m[nh][nw] == 0) { m[nh][nw] = 2 * kind; dfs(nw, nh, kind); }
      if(m[nh][nw] == -2 * kind) { m[nh][nw] = 9; dfs(nw, nh, kind); }
    }
  }
}

int main(){
  while(cin >> w >> h and w + h){
    memset(m, 0, sizeof(m));
    REP(i, h){
      string tmp; cin >> tmp;
      REP(j, w) if(tmp[j] == 'B') m[i][j] = 1; else if(tmp[j] == 'W') m[i][j] = -1;
    }
    REP(i, h) REP(j, w){
      if(m[i][j] == 1) dfs(j, i, 1);
      if(m[i][j] == -1) dfs(j, i, -1);
    }
    int bres = 0; int wres = 0;
    REP(i, h) REP(j, w) {
      if(m[i][j] == 2) bres++;
      if(m[i][j] == -2) wres++;
    }
    cout << bres << " " << wres << endl;
  }
  return 0;
}