#include <bits/stdc++.h>
using namespace std;
char grid[50][50];
int W, H;
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
char c[2] = {'B', 'W'};
int bfs(int sx, int sy, int k) {
  queue<pair<int, int> > que;
  int res[2] = {0};
  bool flag = true;
  que.push(pair<int, int>(sx, sy));
  while (!que.empty()) {
    pair<int, int> p = que.front();
    que.pop();
    if (grid[p.first][p.second] == '.') {
      grid[p.first][p.second] = c[k];
      res[k]++;
    } else
      continue;
    for (int i = 0; i < 4; i++) {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if (0 <= nx && nx < W && 0 <= ny && ny < H && grid[nx][ny] == '.') {
        que.push(pair<int, int>(nx, ny));
        if ((nx + 1 < W && grid[nx + 1][ny] == c[!k]) ||
            (nx - 1 >= 0 && grid[nx - 1][ny] == c[!k]) ||
            (ny + 1 < H && grid[nx][ny + 1] == c[!k]) ||
            (ny - 1 >= 0 && grid[nx][ny - 1] == c[!k]))
          flag = false;
      }
    }
  }
  if (flag == true)
    return res[k];
  else
    return 0;
}
int main() {
  while (cin >> W >> H, W + H) {
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cin >> grid[j][i];
      }
    }
    int ans[2] = {0};
    for (int k = 0; k < 2; k++) {
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (grid[j][i] == '.') {
            if ((j + 1 < W && grid[j + 1][i] == c[k]) ||
                (j - 1 >= 0 && grid[j - 1][i] == c[k]) ||
                (i + 1 < H && grid[j][i + 1] == c[k]) ||
                (i - 1 >= 0 && grid[j][i - 1] == c[k]))
              ans[k] += bfs(j, i, k);
          }
        }
      }
    }
    cout << ans[0] << " " << ans[1] << endl;
  }
}
