#include<bits/stdc++.h>
using namespace std;
int W,H;
int used[100][100];
char fie[100][100];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int solve(int x,int y,int &c){
  if( used[x][y] ) return 0;
  used[x][y] = 1;
  c++;
  int st = 0;
  for(int i=0;i<4;i++){
    int nx = x + dx[i], ny = y + dy[i];
    if( nx < 0 || ny < 0 || nx > W-1 || ny > H-1 ) continue;
    if( fie[nx][ny] == 'W' ) st |= 2;
    if( fie[nx][ny] == 'B' ) st |= 1;
    if( fie[nx][ny] == '.' ) st |= solve(nx,ny,c);
  }
  return st;
}

int main(){
  while ( cin >> W >> H ){
    if( !W & !H ) break;
    for(int i=0;i<H;i++)
      for(int j=0;j<W;j++) cin >> fie[j][i];
    int kc = 0;
    int wc = 0;
    memset(used,0,sizeof(used));
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	if( fie[j][i] == '.' ){
	  int c = 0;
	  int st = solve(j,i,c);
	  if( st == 1 ) kc+=c;
	  else if ( st == 2 ) wc+=c;
	}
      }
    }
    cout << kc << " " << wc << endl;
	
  }
}