#include <bits/stdc++.h>
using namespace std;
long long h, w;
long long dy[4] = {1, -1, 0, 0};
long long dx[4] = {0, 0, 1, -1};
long long f[50][50];
bool contain(long long y, long long x) {
  return (0 <= y && y < h && 0 <= x && x < w);
}
signed main() {
  while (1) {
    cin >> w >> h;
    if (h + w == 0) break;
    vector<string> s(h);
    for (long long i = 0; i < h; i++) cin >> s[i];
    for (long long i = 0; i < h; i++)
      for (long long j = 0; j < w; j++) f[i][j] = 0;
    long long bc = 0, wc = 0;
    for (long long i = 0; i < h; i++) {
      for (long long j = 0; j < w; j++) {
        if (s[i][j] == '.') continue;
        queue<pair<long long, long long> > q;
        q.push(pair<long long, long long>(i, j));
        long long bt = (s[i][j] == 'W' ? 1 : 0);
        while (!q.empty()) {
          pair<long long, long long> p = q.front();
          q.pop();
          for (long long k = 0; k < 4; k++) {
            long long ny = p.first;
            +dy[k];
            long long nx = p.second;
            +dx[k];
            if (!contain(ny, nx)) continue;
            if (s[ny][nx] == '.') {
              if (f[ny][nx] & (1 << bt)) continue;
              f[ny][nx] |= (1 << bt);
              q.push(pair<long long, long long>(ny, nx));
            }
          }
        }
      }
    }
    for (long long i = 0; i < h; i++) {
      for (long long j = 0; j < w; j++) {
        if (f[i][j] == 1) bc++;
        if (f[i][j] == 2) wc++;
      }
    }
    cout << bc << " " << wc << endl;
  }
}
