#include <bits/stdc++.h>
using namespace std;
char a[50][50];
int judge[50][50];
bool visitedw[50][50];
bool visitedb[50][50];
bool searchedw[50][50];
bool searchedb[50][50];
pair<int, int> white[50 * 50];
pair<int, int> black[50 * 50];
int countw;
int countb;
int p[4] = {1, 0, -1, 0}, q[4] = {0, 1, 0, -1};
void print_number(int w, int h) {
  int sumb = 0, sumw = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (judge[i][j] == 2)
        sumb++;
      else if (judge[i][j] == 1)
        sumw++;
    }
  }
  cout << sumb << ' ' << sumw << endl;
}
void dfs_b(int w, int h, int x, int y) {
  for (int i = 0; i < 4; i++) {
    int s = x + p[i], t = y + q[i];
    if (0 <= s && s <= w && 0 <= t && t <= h && a[t][s] == '.' &&
        !searchedb[t][s]) {
      judge[t][s] += 2;
      searchedb[t][s] = true;
      dfs_b(w, h, s, t);
    }
  }
}
void dfs_w(int w, int h, int x, int y) {
  for (int i = 0; i < 4; i++) {
    int s = x + p[i], t = y + q[i];
    if (0 <= s && s <= w && 0 <= t && t <= h && a[t][s] == '.' &&
        !searchedw[t][s]) {
      judge[t][s] += 1;
      searchedw[t][s] = true;
      dfs_w(w, h, s, t);
    }
  }
}
void count_black(int w, int h) {
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == 'B') {
        black[countb].first = j;
        black[countb].second = i;
        countb++;
      }
    }
  }
}
void count_white(int w, int h) {
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == 'W') {
        white[countw].first = j;
        white[countw].second = i;
        countw++;
      }
    }
  }
}
void clear_array() {
  for (int i = 0; i < 50; i++) {
    for (int j = 0; j < 50; j++) {
      judge[i][j] = 0;
      visitedw[i][j] = visitedb[i][j] = false;
      searchedw[i][j] = searchedb[i][j] = false;
    }
  }
}
int main() {
  while (true) {
    int w, h;
    cin >> w >> h;
    if (w == 0 && h == 0) return 0;
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++) cin >> a[i][j];
    clear_array();
    countw = countb = 0;
    count_white(w, h);
    count_black(w, h);
    for (int i = 0; i < countw; i++) {
      dfs_w(w, h, white[i].first, white[i].second);
    }
    for (int i = 0; i < countb; i++) {
      dfs_b(w, h, black[i].first, black[i].second);
    }
    print_number(w, h);
  }
}
