#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX / 3;
const double EPS = 1e-14;
template <typename U, typename T>
void chmin(U &x, T y) {
  x = min(x, y);
}
template <typename U, typename T>
void chmax(U &x, T y) {
  x = max(x, y);
}
int W, H;
const int HMAX = 58, WMAX = 58;
char field[HMAX][WMAX];
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
bool outof_range(int h, int w) { return h < 0 || W <= h || w < 0 || W <= w; }
void dfs(int h, int w, char c, char target) {
  if (outof_range(h, w) or field[h][w] != target) {
    return;
  }
  field[h][w] = c;
  for (int dir = 0; dir < (4); dir++) {
    dfs(h + dy[dir], w + dx[dir], c, target);
  }
}
int main() {
  cout << fixed << setprecision(10);
  while (cin >> W >> H and W) {
    for (int y = 0; y < (HMAX); y++)
      for (int x = 0; x < (WMAX); x++) {
        field[y][x] = '#';
      }
    for (int y = 0; y < (H); y++) {
      string row;
      cin >> row;
      for (int x = 0; x < (W); x++) {
        field[y][x] = row[x];
      }
    }
    for (int y = 0; y < (H); y++)
      for (int x = 0; x < (W); x++) {
        if (field[y][x] == 'W') {
          for (int i = 0; i < (4); i++) {
            dfs(y + dy[i], x + dx[i], 'w', '.');
          }
        }
        if (field[y][x] == 'B') {
          for (int i = 0; i < (4); i++) {
            dfs(y + dy[i], x + dx[i], 'b', '.');
          }
        }
      }
    for (int y = 0; y < (H); y++)
      for (int x = 0; x < (W); x++) {
        if (field[y][x] == 'W') {
          for (int i = 0; i < (4); i++) {
            dfs(y + dy[i], x + dx[i], 'x', 'b');
          }
        }
        if (field[y][x] == 'B') {
          for (int i = 0; i < (4); i++) {
            dfs(y + dy[i], x + dx[i], 'x', 'w');
          }
        }
      }
    int white = 0, black = 0;
    for (int y = 0; y < (H); y++)
      for (int x = 0; x < (W); x++) {
        char c = field[y][x];
        if (c == 'w') {
          white++;
        }
        if (c == 'b') {
          black++;
        }
      }
    cout << black << " " << white << endl;
  }
  return 0;
}
