#include <bits/stdc++.h>
using namespace std;
char t[100][100];
bool visited[100][100];
bool a, b;
int h, w, cnt;
void rec(int y, int x) {
  if (t[y][x] == 'B') a = true;
  if (t[y][x] == 'W') b = true;
  if (t[y][x] != '.') return;
  if (visited[y][x]) return;
  visited[y][x] = true;
  cnt++;
  if (y > 0) rec(y - 1, x);
  if (y + 1 < h) rec(y + 1, x);
  if (x > 0) rec(y, x - 1);
  if (x + 1 < w) rec(y, x + 1);
}
int main() {
  while (1) {
    cin >> h >> w;
    if (h == 0 && w == 0) break;
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++) cin >> t[i][j], visited[i][j] = false;
    int suma = 0, sumb = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (visited[i][j]) continue;
        if (t[i][j] != '.') continue;
        a = b = cnt = false;
        rec(i, j);
        if (a && !b)
          suma += cnt;
        else if (!a && b)
          sumb += cnt;
      }
    }
    cout << suma << ' ' << sumb << endl;
  }
}
