#include <bits/stdc++.h>
using namespace std;

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};

struct Status {
  bool b, w;
  Status() : b(false), w(false) {}
};

char a[51][51];
int w, h;

int dfs(int y, int x, Status &s) {
  if (a[y][x] == 'W') {
    s.w = true;
    return 0;
  }
  if (a[y][x] == 'B') {
    s.b = true;
    return 0;
  }

  int count = 1;
  a[y][x] = 'D';
  rep(i, 4) {
    int nx = x + dx[i];
    int ny = y + dy[i];

    if (0 <= nx && nx < w && 0 <= ny && ny < h && a[ny][nx] != 'D') {
      count += dfs(ny, nx, s);
    }
  }

  return count;
}

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  while (cin >> w >> h, w || h) {
    rep(i, h) rep(j, w) cin >> a[i][j];

    int cnt_w = 0;
    int cnt_b = 0;

    rep(i, h) rep(j, w) {
      if (a[i][j] == '.') {
        Status s;
        int count = dfs(i, j, s);
        if (s.w && s.b) continue;
        if (s.w) cnt_w += count;
        if (s.b) cnt_b += count;
      }
    }

    cout << cnt_b << " " << cnt_w << endl;
  }
  return 0; 
}