#include <bits/stdc++.h>
using namespace std;
struct data {
  int x;
  int y;
};
struct mapData {
  int black = 0;
  int white = 0;
};
int main() {
  int w, h;
  int dx[4] = {1, 0, -1, 0};
  int dy[4] = {0, 1, 0, -1};
  while (cin >> w >> h && w != 0 || h != 0) {
    char map[50][50];
    for (int i = 0; i < h; i++) {
      cin >> map[i];
    }
    mapData whiteBlack[50][50];
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        whiteBlack[i][j].black = 0;
        whiteBlack[i][j].white = 0;
      }
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (map[i][j] == '.') continue;
        int color = (map[i][j] == 'B' ? 1 : 2);
        queue<data> q;
        data first;
        first.x = j;
        first.y = i;
        q.push(first);
        while (q.size() > 0) {
          data d = q.front();
          q.pop();
          if (map[d.y][d.x] == '.') {
            if (color == 1) {
              whiteBlack[d.y][d.x].black = 1;
            } else {
              whiteBlack[d.y][d.x].white = 1;
            }
          }
          for (int k = 0; k < 4; k++) {
            int nx = dx[k] + d.x;
            int ny = dy[k] + d.y;
            if (nx >= w || ny >= h || nx < 0 || ny < 0) continue;
            if (map[ny][nx] == 'W' || map[ny][nx] == 'B') continue;
            if (color == 1 && whiteBlack[ny][nx].black == 1) continue;
            if (color == 2 && whiteBlack[ny][nx].white == 1) continue;
            data add;
            add.x = nx;
            add.y = ny;
            q.push(add);
          }
        }
      }
    }
    int white = 0;
    int black = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (whiteBlack[i][j].black == 1 && whiteBlack[i][j].white == 0) {
          black++;
        } else if (whiteBlack[i][j].white == 1 && whiteBlack[i][j].black == 0) {
          white++;
        }
      }
    }
    cout << black << " " << white << endl;
  }
  return 0;
}
