#include <bits/stdc++.h>
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
using namespace std;
int main() {
  int H, W;
  while (true) {
    cin >> H >> W;
    if (!H) break;
    vector<vector<char>> mp(H, vector<char>(W));
    vector<vector<int>> c(H, vector<int>(W, 0));
    for (int i = 0; i < (H); i++)
      for (int j = 0; j < (W); j++) cin >> mp[i][j];
    int Bct = 0;
    int Wct = 0;
    for (int i = 0; i < (H); i++) {
      for (int j = 0; j < (W); j++) {
        if (!c[i][j]) {
          queue<pair<int, int>> que;
          que.push(make_pair(i, j));
          int ct = 0;
          bool isBlack = false;
          bool isWhite = false;
          while (que.size()) {
            int x = que.front().first;
            int y = que.front().second;
            que.pop();
            for (int k = 0; k < (4); k++) {
              int nx = x + dx[k];
              int ny = y + dy[k];
              if (nx < H && nx >= 0 && ny < W && ny >= 0) {
                if (mp[nx][ny] == 'B')
                  isBlack = true;
                else if (mp[nx][ny] == 'W')
                  isWhite = true;
                else if (c[nx][ny] == 0) {
                  ct++;
                  que.push(make_pair(nx, ny));
                }
                c[nx][ny] = 1;
              }
            }
          }
          if (isBlack && !isWhite)
            Bct += ct;
          else if (isWhite && !isBlack)
            Wct += ct;
        }
      }
    }
    cout << Bct << " " << Wct << endl;
  }
  return 0;
}
