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

using namespace std;


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

int main()
{
	int w,h;
	while(cin>>w>>h,w||h){
		vector<string> p(h);
		for(int i=0;i<h;i++) cin>>p[i];

		int resB=0,resW=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				bool black=false,white=false;
				if(p[i][j]=='.'){
					vector<vector<bool> > vis(h,vector<bool>(w,false));
					queue<pair<int,int> > q;
					q.push(make_pair(i,j));

					while(!q.empty()){
						int y=q.front().first,x=q.front().second;
						q.pop();
						if(vis[y][x]) continue;

						vis[y][x]=true;

						if(p[y][x]=='W'){ white=true; continue;}
						if(p[y][x]=='B'){ black=true; continue;}

						for(int k=0;k<4;k++){
							int ny=y+dy[k],nx=x+dx[k];
							if(ny<0 || ny>=h || nx<0 || nx>=w) continue;
							q.push(make_pair(ny,nx));
						}
					}

				}
/*
				cout<<i<<" "<<j<<":";
				if(black) cout<<"B";
				if(white) cout<<"W";
				cout<<endl;
*/
				if(black && !white) resB++;
				if(!black && white) resW++;
			}
		}

		cout<<resB<<" "<<resW<<endl;

	}

	return 0;
}