#include <bits/stdc++.h>
using namespace std;
int w = 0, b = 0;
int n, m;
char d[50][50];
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
void bfs(int x, int y, char s) {
  queue<pair<int, int> > q;
  q.push(pair<int, int>(x, y));
  while (q.size()) {
    pair<int, int> p = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      int x = p.first + dx[i], y = p.second + dy[i];
      if (0 <= x && x < m && 0 <= y && y < n) {
        if (d[x][y] == '.') {
          d[x][y] = s == 'W' ? '@' : '*';
          s == 'W' ? b++ : w++;
          q.push(pair<int, int>(x, y));
        } else if (d[x][y] == (s == 'W' ? '*' : '@')) {
          d[x][y] = s == 'W' ? '@' : '*';
          s == 'W' ? w-- : b--;
          q.push(pair<int, int>(x, y));
        }
      }
    }
  }
}
int main() {
  while (cin >> n >> m, (n || m)) {
    for (int i = 0; i < m; i++) {
      cin >> d[i];
    }
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
        if (d[i][j] == 'W') {
          bfs(i, j, 'W');
        }
      }
    }
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
        if (d[i][j] == 'B') {
          bfs(i, j, 'B');
        }
      }
    }
    cout << w << " " << b << endl;
    w = b = 0;
  }
  return 0;
}
