#include <iostream>
#include <algorithm>

using namespace std;

int w, h;
char input[50][50];
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};
bool touched[2][50][50];

bool isOver(int y, int x){
  if(y<0 || y>=h) return true;
  if(x<0 || x>=w) return true;
  return false;
}

void dfs(int y, int x, int p){
  touched[p][y][x] = true;
  for(int i=0;i<4;i++){
    int ny = y + dy[i];
    int nx = x + dx[i];
    if(isOver(ny, nx)) continue;
    if(input[ny][nx] != '.') continue;
    if(touched[p][ny][nx]) continue;
    dfs(ny, nx, p);
  }
}

int main(){
  while(cin >> w >> h && (w|h)){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> input[i][j];
      }
    }
    fill(touched[0][0], touched[2][0], false);
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(input[i][j] == '.'){
          for(int k=0;k<4;k++){
            int ny = i + dy[k];
            int nx = j + dx[k];
            if(isOver(ny, nx)) continue;
            if(input[ny][nx] == 'B' && !touched[0][i][j]) dfs(i, j, 0);
            if(input[ny][nx] == 'W' && !touched[1][i][j]) dfs(i, j, 1);
          }
        }
      }
    }
    int ans1 = 0, ans2 = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(touched[0][i][j] && !touched[1][i][j]) ans1++;
        if(!touched[0][i][j] && touched[1][i][j]) ans2++;
      }
    }
    cout << ans1 << ' ' << ans2 << endl;
  }
  return 0;
}