#include <bits/stdc++.h>
using namespace std;
int w, h;
int dd[8] = {0, 1, 0, -1, 0};
void bfs(char map[50][50]) {
  int bc = 0, wc = 0;
  for (int i = 0; i < (h); i++) {
    for (int j = 0; j < (w); j++) {
      if (map[j][i] == '.') {
        queue<pair<int, int> > q;
        q.push(pair<int, int>(j, i));
        int count = 0;
        pair<int, int> state = pair<int, int>(0, 0);
        while (!q.empty()) {
          int cx = q.front().first, cy = q.front().second;
          q.pop();
          if (map[cx][cy] == '.') count++;
          map[cx][cy] = '#';
          for (int r = 0; r < (4); r++) {
            int nx = cx + dd[r], ny = cy + dd[r + 1];
            if (nx < 0 || ny < 0 || nx >= w || ny >= h || map[nx][ny] == '#')
              continue;
            if (map[nx][ny] == 'B') {
              state.first = 1;
              continue;
            }
            if (map[nx][ny] == 'W') {
              state.second = 1;
              continue;
            }
            q.push(pair<int, int>(nx, ny));
          }
        }
        if (state == pair<int, int>(1, 0)) bc += count;
        if (state == pair<int, int>(0, 1)) wc += count;
      }
    }
  }
  printf("%d %d\n", bc, wc);
}
int main() {
  for (;;) {
    cin >> w >> h;
    if (!(w + h)) break;
    char map[50][50];
    for (int i = 0; i < (h); i++) {
      for (int j = 0; j < (w); j++) {
        cin >> map[j][i];
      }
    }
    bfs(map);
  }
}
