#include <bits/stdc++.h>
using namespace std;
int w, h;
bool check(int x, int y) { return x >= 0 && x < w && y >= 0 && y < h; }
int main() {
  int dx[] = {1, 0, -1, 0};
  int dy[] = {0, 1, 0, -1};
  while (cin >> w >> h && (w || h)) {
    string a;
    int cntB = 0, cntW = 0;
    vector<string> maze;
    for (int i = 0; i < h; ++i) {
      cin >> a;
      maze.push_back(a);
    }
    for (int y = 0; y < h; ++y) {
      for (int x = 0; x < w; ++x) {
        if (maze[y][x] != '.') continue;
        bool white = false, black = false;
        queue<pair<int, int> > que;
        bool visited[64][64] = {0};
        que.push(pair<int, int>(x, y));
        while (!que.empty()) {
          pair<int, int> p = que.front();
          que.pop();
          int px = p.first;
          int py = p.second;
          visited[py][px] = true;
          if (maze[py][px] == 'W') {
            white = true;
            continue;
          }
          if (maze[py][px] == 'B') {
            black = true;
            continue;
          }
          for (int i = 0; i < 4; ++i) {
            int nx = px + dx[i];
            int ny = py + dy[i];
            if (check(nx, ny) && !visited[ny][nx])
              que.push(pair<int, int>(nx, ny));
          }
        }
        if (!white && black)
          cntB++;
        else if (white && !black)
          cntW++;
      }
    }
    cout << cntB << " " << cntW << endl;
  }
  return 0;
}
