#include <bits/stdc++.h>
using namespace std;
vector<string> f(10);
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int w, h;
void rec(int x, int y, char c) {
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
    if (f[ny][nx] == '.') {
      f[ny][nx] = (c == 'B' ? 'b' : 'w');
      rec(nx, ny, c);
    } else if ((f[ny][nx] == 'b' && c == 'W') ||
               (f[ny][nx] == 'w' || c == 'B')) {
      f[ny][nx] = 'o';
      rec(nx, ny, c);
    }
  }
}
int main() {
  while (cin >> w >> h, (w || h)) {
    f.clear();
    for (int y = 0; y < h; y++) {
      string s;
      cin >> s;
      f.push_back(s);
    }
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        if (f[y][x] == 'W' || f[y][x] == 'B') rec(x, y, f[y][x]);
      }
    }
    int blacks = 0, whites = 0;
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        if (f[y][x] == 'b')
          blacks++;
        else if (f[y][x] == 'w')
          whites++;
      }
    }
    cout << blacks << " " << whites << endl;
  }
  return 0;
}
