#include<iostream>
#include<climits>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb         push_back
#define mp         make_pair
#define ALL(C)     (C).begin(),(C).end()


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

int vis[50][50];
char m[50][50];


void dfs(int r,int c,int y,int x,int now){
  if(((1<<now)&vis[y][x]) != 0)return;
  vis[y][x]|=(1<<now);
  rep(i,4){
    int nex=x+dx[i],ney=y+dy[i];
    if (nex==-1||nex==c||ney==r||ney==-1||m[ney][nex]!='.')continue;
    dfs(r,c,ney,nex,now);
  }
}

void solve(int r,int c){
  rep(i,r){
    rep(j,c){
      vis[i][j]=0;
    }
  }
   
  rep(i,r){
    rep(j,c){
      if (m[i][j] == 'B'){
	dfs(r,c,i,j,0);
      }else if (m[i][j] == 'W'){
	dfs(r,c,i,j,1);
      }
    }
  }

  int w=0,b=0;
  rep(i,r){
    rep(j,c){
      if (m[i][j] != '.')continue;
      if (vis[i][j] == 1)b++;
      else if (vis[i][j]==2)w++;
    }
  }
  cout << b << " " << w << endl;
}

int main(){
  int r,c;
  while(cin>>c>>r && c){
    rep(i,r){
      rep(j,c)cin>>m[i][j];
    }
    solve(r,c);
  }
}