#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1.0);
const double inf = (int)1e8;
int w, h;
string field[50];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
bool isIn(int x, int y) { return 0 <= x && x < h && 0 <= y && y < w; }
int check(int x, int y) {
  bool used[50][50];
  for (int i = 0; i < w; i++)
    for (int j = 0; j < h; j++) used[i][j] = false;
  int result = 0;
  queue<pair<int, int> > q;
  q.push(make_pair(x, y));
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    if (used[p.first][p.second]) continue;
    used[p.first][p.second] = true;
    for (int i = 0; i < 4; i++) {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if (!isIn(nx, ny) || used[nx][ny]) continue;
      if (field[nx][ny] != '.') {
        if (result == 0) {
          if (field[nx][ny] == 'W')
            result = 1;
          else
            result = 2;
        } else {
          if (result == 2 && field[nx][ny] == 'W')
            return -1;
          else if (result == 1 && field[nx][ny] == 'B')
            return -1;
        }
      } else {
        q.push(make_pair(nx, ny));
      }
    }
  }
  return result;
}
int main() {
  while (cin >> w >> h, w + h) {
    for (int i = 0; i < h; i++) cin >> field[i];
    int a = 0, b = 0;
    bool is[50][50];
    for (int i = 0; i < 50; i++)
      for (int j = 0; j < 50; j++) is[i][j] = false;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (field[i][j] == '.' && !is[i][j]) {
          int r = check(i, j);
          int count = 0;
          queue<pair<int, int> > q;
          q.push(make_pair(i, j));
          while (!q.empty()) {
            pair<int, int> p = q.front();
            q.pop();
            if (is[p.first][p.second]) continue;
            is[p.first][p.second] = true;
            count++;
            for (int i = 0; i < 4; i++) {
              int nx = p.first + dx[i], ny = p.second + dy[i];
              if (!isIn(nx, ny) || is[nx][ny]) continue;
              if (field[nx][ny] == '.') q.push(make_pair(nx, ny));
            }
          }
          if (r == 1) {
            a += count;
            field[i][j] = 'W';
          } else if (r == 2) {
            b += count;
            field[i][j] = 'B';
          }
        }
      }
    }
    cout << b << " " << a << endl;
  }
}
