#include <bits/stdc++.h>
using namespace std;
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
int w, h;
vector<string> a;
bool solve(int x, int y, char c) {
  if (!(0 <= x && x < h && 0 <= y && y < w)) return true;
  if ((a[x][y] == '@') || (c == 'W' && a[x][y] == 'B') ||
      (c == 'B' && a[x][y] == 'W'))
    return false;
  if ((a[x][y] == ':') || (c == a[x][y]) || (c == 'W' && a[x][y] == 'w') ||
      (c == 'B' && a[x][y] == 'b'))
    return true;
  a[x][y] = ':';
  bool flag = true;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (!solve(nx, ny, c)) {
      flag = false;
      break;
    }
  }
  if (flag) {
    if (c == 'W')
      a[x][y] = 'w';
    else if (c == 'B')
      a[x][y] = 'b';
    return true;
  } else {
    a[x][y] = '@';
    return false;
  }
}
int main() {
  while (cin >> w >> h, !(w == 0 && h == 0)) {
    a.clear();
    for (int i = 0; i < h; i++) {
      string tmp;
      cin >> tmp;
      a.push_back(tmp);
    }
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++)
        if (a[i][j] == 'W')
          for (int k = 0; k < 4; k++) solve(i + dx[k], j + dy[k], 'W');
        else if (a[i][j] == 'B')
          for (int k = 0; k < 4; k++) solve(i + dx[k], j + dy[k], 'B');
    int wcnt = 0, bcnt = 0;
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++)
        if (a[i][j] == 'w')
          wcnt++;
        else if (a[i][j] == 'b')
          bcnt++;
    cout << bcnt << " " << wcnt << endl;
  }
  return 0;
}
