#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(void) {
  int w, h;
  while (cin >> w >> h, w) {
    bool black[h][w], white[h][w];
    memset(black, 0, sizeof(black));
    memset(white, 0, sizeof(white));
    string in[h];
    for (int i = 0; i < h; i++) {
      cin >> in[i];
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        int f = 0;
        if (in[i][j] == 'W')
          f = 1;
        else if (in[i][j] == 'B')
          f = 2;
        if (in[i][j] != '.') {
          bool used[h][w];
          memset(used, 0, sizeof(used));
          queue<int> xs, ys;
          xs.push(j);
          ys.push(i);
          while (!xs.empty()) {
            int x = xs.front(), y = ys.front();
            xs.pop();
            ys.pop();
            used[y][x] = true;
            if (f == 1)
              white[y][x] = true;
            else
              black[y][x] = true;
            for (int k = 0; k < 4; k++) {
              int nx = x + dx[k], ny = y + dy[k];
              if (0 <= nx && nx < w && 0 <= ny && ny < h && !used[ny][nx] &&
                  in[ny][nx] == '.') {
                xs.push(nx);
                ys.push(ny);
              }
            }
          }
        }
      }
    }
    int Black = 0, White = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (in[i][j] != 'B' && black[i][j] && !white[i][j])
          Black++;
        else if (in[i][j] != 'W' && !black[i][j] && white[i][j])
          White++;
      }
    }
    cout << Black << " " << White << endl;
  }
  return 0;
}
