#include <bits/stdc++.h>
using namespace std;
int w, h;
char a[50][50];
bool flag[50][50];
int dd[5] = {0, -1, 0, 1, 0};
int dfs(int x, int y, char color) {
  if (x < 0 || x >= w || y < 0 || y >= h || flag[x][y] || a[x][y] == color)
    return 0;
  if (a[x][y] != '.') return -1;
  flag[x][y] = true;
  int ret = 1;
  for (int i = 0; i < 4; i++) {
    int cs = dfs(x + dd[i], y + dd[i + 1], color);
    if (cs == -1) ret = -1;
    if (ret > 0) ret += cs;
  }
  return ret;
}
int main() {
  while (cin >> w >> h, w) {
    for (int i = 0; i < h * w; i++) {
      flag[i % w][i / w] = false;
      cin >> a[i % w][i / w];
    }
    int r[2] = {0, 0};
    char c[2] = {'B', 'W'};
    for (int k = 0; k < 2; k++) {
      for (int i = 0; i < w * h; i++) flag[i % w][i / w] = false;
      for (int i = 0; i < w * h; i++) {
        int a = dfs(i % w, i / w, c[k]);
        r[k] += (a >= 0) ? a : 0;
      }
    }
    cout << r[0] << " " << r[1] << endl;
  }
  return 0;
}
