#include<iostream>
#include<cstdio>
#include<cstring>

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};

#define REP(i,n) for(int i = 0; i<(n); i++)

void dfsw(int y, int x){
  w[y][x] == true;
  REP(i,4){
    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;
  REP(i,4){
    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));
    REP(i,hh) scanf("%s",d[i]);
    REP(i,hh) REP(j,ww){
      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;
    //REP(i,hh){ REP(j,ww) putchar(w[i][j]?'w':'.'); puts("");}
    //REP(i,hh){ REP(j,ww) putchar(b[i][j]?'b':'.'); puts("");}
    REP(i,hh) REP(j,ww){
      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);
  }
}