#include <bits/stdc++.h>
using namespace std;
char table[50][50];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int g_count[2];
void breadth(int x, int y) {
  std::vector<pair<int, int>> queue;
  queue.emplace_back(x, y);
  set<char> owner;
  table[x][y] = 'H';
  int count = 1;
  while (!queue.empty()) {
    auto a = queue.back();
    int x = a.first;
    int y = a.second;
    queue.pop_back();
    for (int i = 0; i < 4; ++i) {
      if (table[x + dx[i]][y + dy[i]] == '.') {
        ++count;
        queue.emplace_back(x + dx[i], y + dy[i]);
        table[x + dx[i]][y + dy[i]] = 'H';
      } else {
        owner.insert(table[x + dx[i]][y + dy[i]]);
      }
    }
  }
  if (owner.count('W') != 0 && owner.count('B') == 0) {
    g_count[1] += count;
  } else if (owner.count('W') == 0 && owner.count('B') != 0) {
    g_count[0] += count;
  }
}
int main() {
  for (int i = 0; i < 50; ++i) {
    table[i][0] = 'H';
    table[0][i] = 'H';
  }
  while (true) {
    int w, h;
    cin >> w >> h;
    if (w == 0) break;
    g_count[0] = 0;
    g_count[1] = 0;
    for (int y = 1; y <= h; ++y) {
      for (int x = 1; x <= w; ++x) {
        cin >> table[x][y];
      }
    }
    for (int i = 0; i < 50; ++i) {
      table[i][h + 1] = 'H';
      table[w + 1][i] = 'H';
    }
    for (int x = 1; x <= w; ++x) {
      for (int y = 1; y <= h; ++y) {
        if (table[x][y] != '.') continue;
        breadth(x, y);
      }
    }
    cout << g_count[0] << " " << g_count[1] << endl;
  }
}
