#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int h, w;
char grid[51][51];
bool iswhite[51][51];
bool isblack[51][51];
bool issearched[51][51];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
bool dfs(int px, int py, char c, char c2, bool issearched[51][51]) {
  int res = 1;
  for (int i = 0; i < (int)(4); i++) {
    int nx = px + dx[i];
    int ny = py + dy[i];
    if (nx < 0 || ny < 0 || nx > h - 1 || ny > w - 1) continue;
    if (issearched[nx][ny]) continue;
    issearched[nx][ny] = true;
    if (grid[nx][ny] == c)
      return true;
    else if (grid[nx][ny] == '.')
      return dfs(nx, ny, c, c2, issearched);
    else if (grid[nx][ny] == c2)
      return false;
  }
  return false;
}
int main() {
  while (1) {
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    for (int i = 0; i < (int)(h); i++)
      for (int j = 0; j < (int)(w); j++) cin >> grid[i][j];
    for (int i = 0; i < (int)(h); i++)
      for (int j = 0; j < (int)(w); j++) {
        for (int k = 0; k < (int)(h); k++)
          for (int l = 0; l < (int)(w); l++) issearched[k][l] = false;
        iswhite[i][j] = dfs(i, j, 'W', 'B', issearched);
      }
    for (int i = 0; i < (int)(h); i++)
      for (int j = 0; j < (int)(w); j++) {
        for (int k = 0; k < (int)(h); k++)
          for (int l = 0; l < (int)(w); l++) issearched[k][l] = false;
        isblack[i][j] = dfs(i, j, 'B', 'W', issearched);
      }
    int white = 0;
    int black = 0;
    for (int i = 0; i < (int)(h); i++)
      for (int j = 0; j < (int)(w); j++) {
        if (iswhite[i][j] == true && isblack[i][j] == false)
          white++;
        else if (iswhite[i][j] == false && isblack[i][j] == true)
          black++;
      }
    cout << black << " " << white;
  }
}
