#include <bits/stdc++.h>
using namespace std;
char m[55][55];
bool used[55][55];
int w, h;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
char c, c_;
bool f;
int solve(int x, int y) {
  int ret = 1;
  used[x][y] = false;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (m[nx][ny] == c) {
      f = true;
    }
    if (m[nx][ny] == c_) {
      return -1000000;
    }
    if (m[nx][ny] == '.' && used[nx][ny]) {
      ret += solve(nx, ny);
    }
  }
  return ret;
}
int main(void) {
  while (1) {
    scanf("%d%d", &w, &h);
    if (!w && !h) break;
    memset(m, 0, sizeof(m));
    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        scanf(" %c", &m[i][j]);
      }
    }
    for (int k = 0; k < 2; k++) {
      int ans = 0;
      memset(used, true, sizeof(used));
      c_ = (k) ? 'B' : 'W';
      c = (!k) ? 'B' : 'W';
      for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
          if (m[i][j] == '.' && used[i][j]) {
            f = false;
            int ret = max(0, solve(i, j));
            if (f) {
              ans += ret;
            }
          }
        }
      }
      printf("%d%c", ans, (k) ? '\n' : ' ');
    }
  }
}
