#include <bits/stdc++.h>
using namespace std;
struct DATA {
  char c;
  bool w;
  bool b;
  DATA() {
    c = '.';
    w = false;
    b = false;
  }
};
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
void f(vector<vector<DATA>> &m, int w, int h) {
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      if (m[y][x].c != '.') continue;
      for (int k = 0; k < 4; k++) {
        int xx = x + dx[k];
        int yy = y + dy[k];
        if (xx < 0 || yy < 0 || xx >= w || yy >= h) continue;
        if (m[yy][xx].c == 'W' || m[yy][xx].w) {
          m[y][x].w = true;
        }
        if (m[yy][xx].c == 'B' || m[yy][xx].b) {
          m[y][x].b = true;
        }
      }
    }
  }
}
int main() {
  while (true) {
    int w, h;
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    vector<vector<DATA>> m(h);
    for (int y = 0; y < h; y++) {
      m[y].resize(w);
      for (int x = 0; x < w; x++) {
        cin >> m[y][x].c;
      }
    }
    for (int i = 0; i < w + h; i++) {
      f(m, w, h);
    }
    int wc = 0, bc = 0;
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        if (m[y][x].c != '.') continue;
        if (m[y][x].w && !m[y][x].b) wc++;
        if (m[y][x].b && !m[y][x].w) bc++;
      }
    }
    cout << bc << " " << wc << endl;
  }
}
