#include <bits/stdc++.h>
#include <stdint.h>

typedef uint32_t u32;
typedef uint64_t u64;
typedef std::pair<int, int> pii;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int w, h;
char a[64][64];
int used[64][64];
int count;
bool black_flag;
bool white_flag;


void dfs(int y, int x) {
  if( not ( 0 <= y and y < h and 0 <= x and x < w ) ) return;
  if( used[y][x] ) return;
  if( a[y][x] != '.' ) {
    if( a[y][x] == 'B' ) black_flag = true;
    if( a[y][x] == 'W' ) white_flag = true;
    return;
  }
  used[y][x] = true;
  count += 1;
  for(int i = 0; i < 4; ++i) {
    dfs(y + dy[i], x + dx[i]);
  }
  return;
}    

int main() {

  for(;;) {
    int B = 0, W = 0;
    std::cin >> w >> h;
    if( w == 0 and h == 0 ) break;
    for(int i = 0; i < h; ++i) for(int j = 0; j < w; ++j) std::cin >> a[i][j];
    for(int i = 0; i < h; ++i) for(int j = 0; j < w; ++j) used[i][j] = false;
    for(int i = 0; i < h; ++i) {
      for(int j = 0; j < w; ++j) {
        count = 0;
        black_flag = white_flag = false;
        dfs(i, j);
        if( black_flag != white_flag ) {
          if( black_flag ) {
            B += count;
          }
          else {
            W += count;
          }
        }
      }
    }
    std::cout << B << ' ' << W << std::endl;
  }                                                           
  
  return 0;
}