#include <bits/stdc++.h>
using namespace std;
char map[50][50];
int acs[50][50] = {0};
int w, h;
int dxy[8][2] = {{1, 0}, {0, 1},  {-1, 0}, {0, -1},
                 {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
void dfs(int y, int x, int type) {
  if (0 <= y && y < h && 0 <= x && x < w) {
    if (map[y][x] == '.' && (acs[y][x] & type) != type) {
      acs[y][x] += type;
      for (int k = 0; k < 8; k++) {
        dfs(y + dxy[1][k], x + dxy[0][k], type);
      }
    }
  }
}
int main() {
  while (cin >> w >> h, w) {
    memset(map, '.', sizeof(map));
    memset(acs, 0, sizeof(acs));
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> map[i][j];
      }
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (map[i][j] == 'B') {
          acs[i][j] = 3;
          for (int k = 0; k < 8; k++) {
            dfs(i + dxy[1][k], j + dxy[0][k], 1);
          }
        } else if (map[i][j] == 'W') {
          acs[i][j] = 3;
          for (int k = 0; k < 8; k++) {
            dfs(i + dxy[1][k], j + dxy[0][k], 2);
          }
        }
      }
    }
    int black = 0;
    int white = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (acs[i][j] == 1) {
          black++;
        } else if (acs[i][j] == 2) {
          white++;
        }
      }
    }
    cout << black << " " << white << endl;
  }
  return 0;
}
