#include <bits/stdc++.h>
using namespace std;

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

int dfs(int y, int x, set<char>& flag, vector<string>& m,vector<vector<int> >& used){


  if(y >= h || y < 0 || x >= w || x < 0) return 0; 
  if(used[y][x] == 1) return 0; // ??¢?´¢??????
  if(m[y][x] == 'B' || m[y][x] == 'W'){
    flag.insert(m[y][x]);
    return 0;
  }


  used[y][x] = 1;  
  int ans = 1;
  for(int i=0; i<4; i++){
    int nx = x + dx[i], ny = y + dy[i];
    ans += dfs(ny,nx,flag,m,used);
  }
  return ans;
}


int main(){

  while(1){
    cin >> w >> h;
    if(!w and !h) break;

    vector<string> m(h);
    for(int j=0; j<h; j++)
      cin >> m[j];

    int bl=0,wh=0;
    vector<vector<int> > used(h,vector<int>(w,0));
    for(int j=0; j<h; j++){
      for(int i=0; i<w; i++){
	if(m[j][i] == '.' and used[j][i] == 0){
	  set<char> flag;
	  int x = dfs(j,i,flag,m,used);
	  if(flag.size() == 1 and *flag.begin() == 'B')
	    bl += x;
	  if(flag.size() == 1 and *flag.begin() == 'W')
	    wh += x;
	}
      }
    }
    cout << bl << " " << wh << endl;
  }
  
}