#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
int dy[4] = {0, 1, 0, -1};
int dx[4] = {1, 0, -1, 0};
int w, h;
void f(char mp[100][100], int y, int x, char a) {
  rep(i, 4) {
    int ny = y + dy[i];
    int nx = x + dx[i];
    if (0 <= ny && ny < h && 0 <= nx && nx < w && mp) {
      if (mp[ny][nx] == '.') {
        mp[ny][nx] = a;
        f(mp, ny, nx, a);
      } else if (mp[ny][nx] == 'w' && a == 'b' || mp[ny][nx] == 'b' && a == 'w') {
        mp[ny][nx] = '#';
        f(mp, ny, nx, a);
      }
    }
  }
}

signed main() {

  while (cin >> w >> h) {
    if (w == 0 && w == 0) break;
    char mp[100][100];
    rep(i, h) rep(j, w) cin >> mp[i][j];

    rep(i, h) {
      rep(j, w) {
        if (mp[i][j] == 'W') {
          f(mp, i, j, 'w');
        } else if (mp[i][j] == 'B') {
          f(mp, i, j, 'b');
        }
      }
    }
    // rep(i, h) {
    //   rep(j, w) cout << mp[i][j];
    //   cout << endl;
    // }
    int white = 0, black = 0;
    rep(i, h) rep(j, w) {
      if (mp[i][j] == 'w')
        white++;
      else if (mp[i][j] == 'b')
        black++;
    }
    cout << black << ' ' << white << endl;
  }
  return 0;
}

