#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int> > board;
int dir[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
void print() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) printf("%5d", board[i][j]);
    puts("");
  }
}
bool solve(int x, int y, int c) {
  if (!(0 <= x && x < n && 0 <= y && y < m)) return true;
  if (board[x][y] == 9999) return true;
  if (board[x][y] == 1000) return false;
  if (board[x][y] == c) return true;
  if (board[x][y] == -c) return false;
  if (board[x][y] == 2 * c) return true;
  if (board[x][y] == -2 * c) return false;
  board[x][y] = 9999;
  bool flag = true;
  for (int i = 0; i < 4; i++) {
    if (!solve(x + dir[i][0], y + dir[i][1], c)) {
      flag = false;
      break;
    }
  }
  if (flag) {
    board[x][y] = c * 2;
    return true;
  } else {
    board[x][y] = 1000;
    return false;
  }
}
int main() {
  while (true) {
    cin >> n >> m;
    board.clear();
    if (n == 0 && m == 0) break;
    for (int i = 0; i < n; i++) {
      vector<int> tmp;
      for (int j = 0; j < m; j++) {
        char c;
        cin >> c;
        int t;
        if (c == '.') t = 0;
        if (c == 'W') t = 1;
        if (c == 'B') t = -1;
        tmp.push_back(t);
      }
      board.push_back(tmp);
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (board[i][j] == 1) {
          for (int k = 0; k < 4; k++) solve(i + dir[k][0], j + dir[k][1], 1);
        }
        if (board[i][j] == -1) {
          for (int k = 0; k < 4; k++) solve(i + dir[k][0], j + dir[k][1], -1);
        }
      }
    }
    int nw = 0, nb = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (board[i][j] == 2)
          nw++;
        else if (board[i][j] == -2)
          nb++;
    printf("%d %d\n", nb, nw);
  }
}
