#include <bits/stdc++.h>
const double PI = acos(-1);
const double EPS = 1e-10;
const int inf = 1e8;
using namespace std;
int sx, sy;
int gx, gy;
vector<vector<int> > tmp;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int co;
vector<vector<char> > in;
bool func(char d, char q, int x, int y) {
  in[x][y] = q;
  co++;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (in[nx][ny] == '.') {
      if (!func(d, q, nx, ny)) return false;
    } else if (in[nx][ny] == d)
      return false;
  }
  return true;
}
int main() {
  int n, m;
  while (cin >> m >> n, m + n) {
    vector<vector<char> > tmp(n + 2, vector<char>(m + 2));
    for (int i = 0; i < n + 2; i++)
      for (int j = 0; j < m + 2; j++) {
        if (!i || !j || i == n + 1 || j == m + 1)
          tmp[i][j] = '!';
        else
          cin >> tmp[i][j];
      }
    in = tmp;
    int b = 0, w = 0;
    for (int i = 0; i < n + 2; i++)
      for (int j = 0; j < m + 2; j++) {
        bool h = false;
        if (in[i][j] == '.') {
          for (int k = 0; k < 4; k++) {
            int nx = i + dx[k];
            int ny = j + dy[k];
            if (in[nx][ny] != 'W' && in[nx][ny] != 'B') continue;
            co = 0;
            if (in[nx][ny] == 'W') {
              if (func('B', 'W', i, j)) w += co;
              break;
            } else {
              if (func('W', 'B', i, j)) b += co;
              break;
            }
          }
        }
      }
    cout << b << " " << w << endl;
  }
}
