#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &os, const vector<T> &t) {
  os << "{";
  for (int(i) = 0; (i) < (t.size()); ++(i)) {
    os << t[i] << ",";
  }
  os << "}" << endl;
  return os;
}
template <class S, class T>
ostream &operator<<(ostream &os, const pair<S, T> &t) {
  return os << "(" << t.first << "," << t.second << ")";
}
int used[60][60], dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
pair<int, int> dfs(vector<string> &mp, int y, int x) {
  if (mp[y][x] == '#') return pair<int, int>(0, 0);
  if (mp[y][x] == 'B') return pair<int, int>(0, 2);
  if (mp[y][x] == 'W') return pair<int, int>(0, 1);
  if (used[y][x]) return pair<int, int>(0, 0);
  used[y][x] = 1;
  pair<int, int> re = pair<int, int>(1, 0), tmp;
  for (int(i) = 0; (i) < (4); ++(i)) {
    tmp = dfs(mp, y + dy[i], x + dx[i]);
    re.first += tmp.first;
    re.second |= tmp.second;
  }
  return re;
}
int main() {
  clock_t St, Et;
  St = clock();
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(0);
  int i, j, k;
  while (1) {
    int w, h;
    cin >> w >> h;
    if (w == 0) break;
    vector<string> mp(h + 2, string(w + 2, '#'));
    for (int(i) = 0; (i) < (h); ++(i)) {
      cin >> mp[i + 1];
      mp[i + 1] = "#" + mp[i + 1] + "#";
    }
    fill(used[0], used[0] + 60 * 60, 0);
    int rew = 0, reb = 0;
    for (i = 1; i <= h; i++)
      for (j = 1; j <= w; j++)
        if (!used[i][j] && mp[i][j] == '.') {
          pair<int, int> tmp = dfs(mp, i, j);
          if (tmp.second == 1) {
            rew += tmp.first;
          } else if (tmp.second == 2) {
            reb += tmp.first;
          }
        }
    cout << reb << " " << rew << endl;
  }
  double hoge = 2;
  while ((clock() - St) / CLOCKS_PER_SEC < 5.0) {
    hoge *= 1.0001;
  }
  return 0;
}
