#include <bits/stdc++.h>
using namespace std;
char mp[55][55];
int n, m, bb, ww;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
void hoge(int h, int w) {
  queue<pair<int, int>> q;
  bool isb = false, isw = false;
  q.push(make_pair(h, w));
  int ret = 0;
  while (!q.empty()) {
    auto now = q.front();
    q.pop();
    mp[now.first][now.second] = '#';
    ret++;
    for (long long(i) = (0); (i) < (4); ++i) {
      int yy = now.first + dy[i];
      int xx = now.second + dx[i];
      if (xx < 0 || yy < 0 || xx >= m || yy >= n) continue;
      if (mp[yy][xx] == '.') q.push(make_pair(yy, xx));
      if (mp[yy][xx] == 'B') isb = true;
      if (mp[yy][xx] == 'W') isw = true;
    }
  }
  if ((isb & isw) || !(isb | isw)) return;
  if (isb)
    bb += ret;
  else
    ww += ret;
}
int main() {
  while (cin >> n >> m, n | m) {
    bb = 0, ww = 0;
    for (long long(i) = (0); (i) < (n); ++i)
      for (long long(j) = (0); (j) < (m); ++j) cin >> mp[i][j];
    for (long long(i) = (0); (i) < (n); ++i)
      for (long long(j) = (0); (j) < (m); ++j) {
        if (mp[i][j] == '.') hoge(i, j);
      }
    cout << bb << ' ' << ww << endl;
  }
  return 0;
}
