#include <iostream>
#include <string>
using namespace std;
int w,h;
string s[51];
const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, 1, 0, -1};

void dfs(int ai, int aj, char c) {
  if (s[ai][aj] == '.') {
    s[ai][aj] = (c == 'W') ? 'w' : 'b' ;
  } else if ((s[ai][aj] == 'b' && c == 'W') ||
             (s[ai][aj] == 'w' && c == 'B')) {
    s[ai][aj] = 'o'; 
  }
  
  for (int z = 0; z < 4; z += 1) {
    int ti = ai + di[z], tj = aj + dj[z];
    if (ti < 0 || tj < 0 || ti >= h || tj >= w) continue;
    if (s[ti][tj] == 'B' || s[ti][tj] == 'W') continue;
    
    if ((s[ti][tj] == '.') || 
      (s[ti][tj] == 'b' && c == 'W') ||
      (s[ti][tj] == 'w' && c == 'B')) {
      dfs(ti, tj, c);
    }
  }
}

void solve() {
  for(int i=0;i<h;i++) cin>>s[i];
  
  for(int i=0;i<h;i++)
  for(int j=0;j<w;j++)
  if (s[i][j] == 'B' || s[i][j] == 'W') {
    dfs(i, j, s[i][j]);
  }
  
  int bc = 0, wc = 0;
  for(int i=0;i<h;i++)
  for(int j=0;j<w;j++)
  if (s[i][j] == 'b') {
    bc++;
  } else if (s[i][j] == 'w') {
    wc++;
  }
  
  cout<<bc<<" "<<wc<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>w>>h, w||h) {
    solve();
  }
  return 0;
}