#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main() {
  while (1) {
    int w, h;
    int aa = 0;
    int bb = 0;
    string a[55];
    string b[55];
    cin >> w >> h;
    if (w == 0) break;
    for (int i = 0; i < h; i++) {
      cin >> a[i];
      b[i] = a[i];
    }
    bool f = true;
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        if (a[y][x] == 'W' || a[y][x] == 'B') f = false;
      }
    }
    if (f) {
      cout << 0 << " " << 0 << endl;
      continue;
    }
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        if (a[y][x] == 'W') {
          queue<pair<int, int> > que;
          que.push(make_pair(x, y));
          while (!que.empty()) {
            int yy = que.front().second;
            int xx = que.front().first;
            a[yy][xx] = 'w';
            que.pop();
            for (int i = 0; i < 4; i++) {
              if (a[yy + dy[i]][xx + dx[i]] == '.') {
                que.push(make_pair(xx + dx[i], yy + dy[i]));
              }
            }
          }
        }
      }
    }
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        if (a[y][x] == '.') {
          bb++;
        }
      }
    }
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        if (b[y][x] == 'B') {
          queue<pair<int, int> > que;
          que.push(make_pair(x, y));
          while (!que.empty()) {
            int yy = que.front().second;
            int xx = que.front().first;
            b[yy][xx] = 'b';
            que.pop();
            for (int i = 0; i < 4; i++) {
              if (b[yy + dy[i]][xx + dx[i]] == '.') {
                que.push(make_pair(xx + dx[i], yy + dy[i]));
              }
            }
          }
        }
      }
    }
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        if (b[y][x] == '.') {
          aa++;
        }
      }
    }
    cout << bb << " " << aa << endl;
  }
  return 0;
}
