#include <bits/stdc++.h>
using namespace std;
long long w, h;
char c[51][51];
long long dy[4] = {1, -1, 0, 0};
long long dx[4] = {0, 0, 1, -1};
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 (w + h == 0) break;
    long long wsum = 0, bsum = 0;
    for (long long i = 0; i < h; i++) {
      for (long long j = 0; j < w; j++) {
        cin >> c[i][j];
        if (c[i][j] == 'W') wsum++;
        if (c[i][j] == 'B') bsum++;
      }
    }
    long long data[51][51] = {};
    for (long long i = 0; i < h; i++) {
      for (long long j = 0; j < w; j++) {
        if (c[i][j] != '.') {
          long long id = (c[i][j] == 'W' ? 1 : 2);
          long long op = id * 2 % 3;
          string str = "?BW";
          if (data[i][j] & id) continue;
          queue<pair<long long, long long> > q;
          q.push(pair<long long, long long>(i, j));
          while (!q.empty()) {
            pair<long long, long long> p = q.front();
            q.pop();
            long long y = p.first;
            long long x = p.second;
            data[y][x] |= id;
            for (long long k = 0; k < 4; k++) {
              long long ny = y + dy[k];
              long long nx = x + dx[k];
              if (!contain(ny, nx)) continue;
              if (c[ny][nx] == str[id]) continue;
              if (data[ny][nx] & id) continue;
              q.push(pair<long long, long long>(ny, nx));
            }
          }
        }
      }
    }
    long long wc = 0, bc = 0;
    for (long long i = 0; i < h; i++) {
      for (long long j = 0; j < w; j++) {
        if (data[i][j] == 1) wc++;
        if (data[i][j] == 2) bc++;
      }
    }
    cout << bc - bsum << " " << wc - wsum << endl;
  }
}
