#include <bits/stdc++.h>
using namespace std;
vector<vector<char> > a(55, vector<char>(55));
vector<vector<int> > mp(55, vector<int>(55));
int bb, ww;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
bool range(int x, int y, int h, int w) {
  if (0 <= x && x < w && 0 <= y && y < h) {
    return true;
  }
  return false;
}
int cc;
void count(int x, int y, int h, int w) {
  for (int i = 0; i < 4; i++) {
    if (range(x + dx[i], y + dy[i], h, w)) {
      if (mp[y + dy[i]][x + dx[i]] == -1) {
        if (a[y + dy[i]][x + dx[i]] == 'B') {
          bb = 1;
        } else if (a[y + dy[i]][x + dx[i]] == 'W') {
          ww = 1;
        }
      } else {
        cc++;
        mp[y + dy[i]][x + dx[i]] = -1;
        count(x + dx[i], y + dy[i], h, w);
      }
    }
  }
  return;
}
int main() {
  int w, h;
  while (cin >> w >> h) {
    if (w == 0 && h == 0) {
      break;
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> a[i][j];
        if (a[i][j] == '.') {
          mp[i][j] = 0;
        } else {
          mp[i][j] = -1;
        }
      }
    }
    int b2, w2;
    b2 = w2 = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        bb = ww = cc = 0;
        if (mp[i][j] != -1) {
          mp[i][j] = -1;
          cc = 1;
          count(j, i, h, w);
          if (bb == 1 && ww == 1) {
          } else if (bb == 1) {
            b2 += cc;
          } else {
            w2 += cc;
          }
        }
      }
    }
    cout << b2 << ' ' << w2 << endl;
  }
  return 0;
}
