#include <bits/stdc++.h>
using namespace std;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main() {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (!(h || w)) break;
    char m[51][51];
    for (int i = (0); i < (h); i++)
      for (int j = (0); j < (w); j++) cin >> m[i][j];
    bool B[50][50], W[50][50];
    for (int i = (0); i < (h); i++)
      for (int j = (0); j < (w); j++) B[i][j] = W[i][j] = false;
    for (int y = (0); y < (h); y++) {
      for (int x = (0); x < (w); x++) {
        if (m[y][x] == '.') continue;
        bool m2[h][w];
        for (int i = (0); i < (h); i++)
          for (int j = (0); j < (w); j++) m2[i][j] = false;
        queue<pair<int, int> > que;
        que.push(pair<int, int>(y, x));
        m2[y][x] = true;
        while (!que.empty()) {
          pair<int, int> tmp = que.front();
          que.pop();
          int ny = tmp.first;
          int nx = tmp.second;
          for (int i = (0); i < (4); i++) {
            int my = ny + dy[i];
            int mx = nx + dx[i];
            if (0 <= my && my < h && 0 <= mx && mx < w && !m2[my][mx] &&
                m[my][mx] == '.') {
              que.push(pair<int, int>(my, mx));
              m2[my][mx] = true;
              if (m[y][x] == 'B')
                B[my][mx] = true;
              else if (m[y][x] == 'W')
                W[my][mx] = true;
            }
          }
        }
      }
    }
    int ans1 = 0, ans2 = 0;
    for (int i = (0); i < (h); i++)
      for (int j = (0); j < (w); j++) {
        if (B[i][j] && !W[i][j])
          ans1++;
        else if (!B[i][j] && W[i][j])
          ans2++;
      }
    cout << ans1 << " " << ans2 << endl;
  }
  return 0;
}
