#include <bits/stdc++.h>
using namespace std;
int w, h;
vector<string> island(51);
pair<int, int> land[51][51];
int dd[] = {1, 0, -1, 0, 1};
bool range(int y, int x) { return 0 <= y && y <= h && 0 <= x && x <= w; }
void dfs(int y, int x, bool b) {
  if (b)
    land[y][x].first = 1;
  else
    land[y][x].second = 1;
  int yy, xx;
  for (int i = (int)(0); i < (int)(4); i++) {
    yy = y + dd[i], xx = x + dd[i + 1];
    if (range(yy, xx)) {
      if (b) {
        if (island[yy][xx] == '.' && land[yy][xx].first == 0) dfs(yy, xx, b);
      } else {
        if (island[yy][xx] == '.' && land[yy][xx].second == 0) dfs(yy, xx, b);
      }
    }
  }
}
int main() {
  cin.sync_with_stdio(false);
  while (cin >> w >> h, w | h) {
    for (int i = (int)(0); i < (int)(h); i++) cin >> island[i];
    for (int i = (int)(0); i < (int)(h); i++)
      for (int j = (int)(0); j < (int)(w); j++)
        land[i][j] = pair<int, int>(0, 0);
    for (int i = (int)(0); i < (int)(h); i++)
      for (int j = (int)(0); j < (int)(w); j++) {
        if (island[i][j] != '.')
          land[i][j] = pair<int, int>(1, 1), dfs(i, j, island[i][j] == 'B');
      }
    int black = 0, white = 0;
    for (int i = (int)(0); i < (int)(h); i++)
      for (int j = (int)(0); j < (int)(w); j++) {
        if (land[i][j].first == 1 && land[i][j].second == 0) black++;
        if (land[i][j].first == 0 && land[i][j].second == 1) white++;
      }
    cout << black << " " << white << endl;
  }
  return 0;
}
