#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
void dfs(vector<vector<char>>& v, int y, int x, bool w, bool b) {
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (v[ny][nx] == 'W') w = true;
    if (v[ny][nx] == 'B') b = true;
    if (!w & !b)
      v[y][x] = '0';
    else if (w & !b)
      v[y][x] = '1';
    else if (!w & b)
      v[y][x] = '2';
    else
      v[y][x] = '3';
    if (v[ny][nx] == '.') {
      dfs(v, ny, nx, w, b);
    }
  }
}
int solve(vector<vector<char>>& v, int y, int x, int& c) {
  c++;
  int m = v[y][x] - '0';
  v[y][x] = '.';
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (v[ny][nx] == '0' || v[ny][nx] == '1' || v[ny][nx] == '2' ||
        v[ny][nx] == '3') {
      m = max(solve(v, ny, nx, c), m);
    }
  }
  return m;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  while (1) {
    int w, h;
    cin >> w >> h;
    if (!w & !h) break;
    vector<vector<char>> field;
    field.push_back(vector<char>(w + 2, '#'));
    for (int i = 0; i < h; i++) {
      vector<char> res;
      string tmp;
      cin >> tmp;
      res.push_back('#');
      for (int j = 0; j < w; j++) {
        res.push_back(tmp[j]);
      }
      res.push_back('#');
      field.push_back(res);
    }
    field.push_back(vector<char>(w + 2, '#'));
    int wCount = 0, bCount = 0, tmp;
    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        if (field[i][j] == '.') {
          dfs(field, i, j, false, false);
        }
      }
    }
    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        if (field[i][j] == '0' || field[i][j] == '1' || field[i][j] == '2' ||
            field[i][j] == '3') {
          int c = 0;
          int m = solve(field, i, j, c);
          if (m == 2) bCount += c;
          if (m == 1) wCount += c;
        }
      }
    }
    cout << bCount << " " << wCount << endl;
  }
}
