#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  int H,W;
  while(true){
    cin >> W >> H;
    if(!H)break;
    vector<vector<char>> mp(H,vector<char>(W));
    vector<vector<int>> c(H,vector<int>(W,0));
      REP(i,H)
      REP(j,W)cin >> mp[i][j];
      int Bct=0;int Wct =0;
    REP(i,H){
      REP(j,W){
	if(!c[i][j] && mp[i][j] == '.'){
	  queue<pair<int,int>> que;
	  que.push(make_pair(i,j));
	  int ct = 1;//????§???§?¨???????
	  c[i][j] = 1;
	  bool isBlack = false;
	  bool isWhite = false;
	  while(que.size()){
	    int x = que.front().first;
	    int y = que.front().second;
	    que.pop();
	    REP(k,4){
	      int nx = x + dx[k];
	      int ny = y + dy[k];
	      if(nx<H&&nx>=0&&ny<W&&ny>=0){
		if(mp[nx][ny] == 'B')isBlack = true;
		else if(mp[nx][ny] == 'W')isWhite = true;
		else if(c[nx][ny] == 0){
		  ct++;
		  que.push(make_pair(nx,ny));
		}
		c[nx][ny] = 1;
	      }
	    }
	  }
	  if(isBlack&&!isWhite)Bct += ct;
	  else if(isWhite&&!isBlack)Wct += ct;
	}
      }
    }
    cout << Bct << " " << Wct << endl;

  }
  return 0;
}