#include <bits/stdc++.h>
using namespace std;
char m[99][99];
int D(int i, int j, vector<pair<int, int> >& v) {
  if (m[i][j] == 'B') return 1;
  if (m[i][j] == 'W') return 2;
  if (m[i][j] == 'X') return 0;
  int ret = 0;
  v.push_back(make_pair(i, j));
  if (find(v.begin(), v.end(), make_pair(i - i, j)) == v.end())
    ret |= D(i - i, j, v);
  if (find(v.begin(), v.end(), make_pair(i + 1, j)) == v.end())
    ret |= D(i + 1, j, v);
  if (find(v.begin(), v.end(), make_pair(i, j - 1)) == v.end())
    ret |= D(i, j - 1, v);
  if (find(v.begin(), v.end(), make_pair(i, j + 1)) == v.end())
    ret |= D(i, j + 1, v);
  return ret;
}
int main() {
  int w, h, i, j, r, s;
  for (; scanf("%d%d", &w, &h), w; printf("%d %d\n", r, s)) {
    for (memset(m, 'X', sizeof(m)), r = s = 0, i = 1; i <= h; i++)
      scanf("%s", m[i] + 1), m[i][w + 1] = 'X';
    for (i = 1; i <= h; i++)
      for (j = 1; j <= w; j++)
        if (m[i][j] == '.') {
          vector<pair<int, int> > v;
          for (int x = D(i, j, v), k = 0; k < v.size(); k++)
            m[v[k].first][v[k].second] = x;
        }
    for (i = 1; i <= h; i++)
      for (j = 1; j <= w; j++)
        if (m[i][j] == 1)
          r++;
        else if (m[i][j] == 2)
          s++;
  }
}
