#include <iostream>
#include <cstdio>
#include <algorithm>
#include <tuple>
#include <cstring>
using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
#define eb emplace_back

int w,h;
char g[55][55];
int flg[55][55];

void draw(int i, int j, int c){
    rep(d,4){
        int di[] = {0,1,0,-1};
        int dj[] = {1,0,-1,0};
        int ni = i+di[d];
        int nj = j+dj[d];
        if(ni >= h || ni < 0 || nj >= w || nj < 0) continue;
        if(g[ni][nj]!='.' || flg[ni][nj]&c) continue;
        flg[ni][nj] |= c;
        draw(ni,nj,c);
    }
}

int main(){
    while(cin >> w >> h && w){
        rep(i,h) cin >> g[i];
        memset(flg,0,sizeof(flg));
        rep(i,h)rep(j,w)if(g[i][j]!='.') draw(i,j,g[i][j]=='W' ? 1 : 2);
        int cb = 0, cw = 0;
        rep(i,h)rep(j,w){
            if(flg[i][j]==1) cw++;
            if(flg[i][j]==2) cb++;
        }
        cout << cb << " " << cw << endl;
    }
}