#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
bool wh[51][51];
bool bl[51][51];
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
vector<string> grid;
int w,h;
void dfs(int x,int y,bool cl[51][51]){
  REP(r,4){
    int nx = x + dx[r];
    int ny = y + dy[r];
    if(nx >=0 && nx < w && ny >= 0 && ny < h){
      if(grid[ny][nx] == '.' && !cl[ny][nx]){
        cl[ny][nx] = true;
        dfs(nx,ny,cl);
      }
    }
  }
}
int main(){
  while(cin>>w>>h,w){
    memset(wh,0,sizeof(wh));
    memset(bl,0,sizeof(bl));
    grid = vector<string>(h);
    REP(i,h)cin>>grid[i];
    REP(y,h)REP(x,w){
      if(grid[y][x]=='W'){
        dfs(x,y,wh);
      }else if(grid[y][x] == 'B'){
        dfs(x,y,bl);
      }
    }
    int ans1=0,ans2=0;
    REP(y,h)REP(x,w){
      if(bl[y][x]&&!wh[y][x])ans1++;
      if(wh[y][x]&&!bl[y][x])ans2++;
    }
    printf("%d %d\n",ans1,ans2);
  }
  
  return 0;
}



  