#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL << 25) // 33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}, w, h, res;
string a[55];
bool isw = false, isb = false;

int dfs(int y, int x) {
  a[y][x] = '#';
  res++;
  REP(i, 4) {
    int nx = x + dx[i], ny = y + dy[i];
    if (nx >= 0 && nx < w && ny >= 0 && ny < h) {
      if (a[ny][nx] == '.')
        dfs(ny, nx);
      if (a[ny][nx] == 'W')
        isw = true;
      if (a[ny][nx] == 'B')
        isb = true;
    }
  }

  return res;
}

signed main(void) {
  while (true) {
    cin >> w >> h;
    if(!w && !h) break;
    REP(i, h) cin >> a[i];

    int nw = 0, nb = 0;
    REP(i, h) REP(j, w) {
      if (a[i][j] == '.') {
        // cout << a[i][j] << " ";
        isw = false;
        isb = false;
        res = 0;
        dfs(i, j);
        if (isw && !isb)
          nw += res;
        else if (!isw && isb)
          nb += res;
        // cout << res << " " << i << " " << j << " " << nb << " " << nw <<
        // endl;
      }
    }

    cout << nb << " " << nw << endl;
  }
  return 0;
}