#include <bits/stdc++.h>
using namespace std;
int xs[] = {-1, 0, 1, 0}, ys[] = {0, 1, 0, -1};
char a[55][55];
int w, h;
bool b[55][55], wh[55][55];
int main() {
  while (cin >> w >> h, w | h) {
    memset(b, 0, sizeof(b));
    memset(wh, 0, sizeof(wh));
    queue<pair<int, int> > black, white;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> a[i][j];
        if (a[i][j] == 'B') black.push(pair<int, int>(i, j));
        if (a[i][j] == 'W') white.push(pair<int, int>(i, j));
      }
    }
    while (!black.empty()) {
      for (int t = black.size() - 1; t >= 0; t--) {
        pair<int, int> tmp = black.front();
        black.pop();
        for (int i = 0; i < 4; i++) {
          int nx = tmp.first + xs[i], ny = tmp.second + ys[i];
          if (nx < 0 || nx >= h || ny < 0 || ny >= w || a[nx][ny] != '.')
            continue;
          if (b[nx][ny]) continue;
          b[nx][ny] = true;
          black.push(pair<int, int>(nx, ny));
        }
      }
    }
    while (!white.empty()) {
      for (int t = white.size() - 1; t >= 0; t--) {
        pair<int, int> tmp = white.front();
        white.pop();
        for (int i = 0; i < 4; i++) {
          int nx = tmp.first + xs[i], ny = tmp.second + ys[i];
          if (nx < 0 || nx > h || ny < 0 || ny > w || a[nx][ny] != '.')
            continue;
          if (wh[nx][ny]) continue;
          wh[nx][ny] = true;
          white.push(pair<int, int>(nx, ny));
        }
      }
    }
    int bc = 0, wc = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (b[i][j] && !wh[i][j]) bc++;
        if (!b[i][j] && wh[i][j]) wc++;
      }
    }
    cout << bc << " " << wc << endl;
  }
  return 0;
}
