#include <bits/stdc++.h>
using namespace std;
int W, H;
int nb, nw;
int n, flag = 1, flag2;
char field[50][50];
int umerub(int y, int x) {
  n++;
  field[x][y] = ',';
  if (x != 0 && field[x - 1][y] == '.') umerub(y, x - 1);
  if (y != 0 && field[x][y - 1] == '.') umerub(y - 1, x);
  if (x != H - 1 && field[x + 1][y] == '.') umerub(y, x + 1);
  if (y != W - 1 && field[x][y + 1] == '.') umerub(y + 1, x);
  if (x != 0 && field[x - 1][y] == 'W') flag = 0;
  if (y != 0 && field[x][y - 1] == 'W') flag = 0;
  if (x != H - 1 && field[x + 1][y] == 'W') flag = 0;
  if (y != W - 1 && field[x][y + 1] == 'W') flag = 0;
  if (x != 0 && field[x - 1][y] == 'B') flag2 = 1;
  if (y != 0 && field[x][y - 1] == 'B') flag2 = 1;
  if (x != H - 1 && field[x + 1][y] == 'B') flag2 = 1;
  if (y != W - 1 && field[x][y + 1] == 'B') flag2 = 1;
  return n;
}
int umeruw(int y, int x) {
  n++;
  field[x][y] = 'W';
  if (x != 0 && field[x - 1][y] == ',') umeruw(y, x - 1);
  if (y != 0 && field[x][y - 1] == ',') umeruw(y - 1, x);
  if (x != H - 1 && field[x + 1][y] == ',') umeruw(y, x + 1);
  if (y != W - 1 && field[x][y + 1] == ',') umeruw(y + 1, x);
  if (x != 0 && field[x - 1][y] == 'B') flag = 0;
  if (y != 0 && field[x][y - 1] == 'B') flag = 0;
  if (x != H - 1 && field[x + 1][y] == 'B') flag = 0;
  if (y != W - 1 && field[x][y + 1] == 'B') flag = 0;
  if (x != 0 && field[x - 1][y] == 'W') flag2 = 1;
  if (y != 0 && field[x][y - 1] == 'W') flag2 = 1;
  if (x != H - 1 && field[x + 1][y] == 'W') flag2 = 1;
  if (y != W - 1 && field[x][y + 1] == 'W') flag2 = 1;
  return n;
}
int main() {
  while (cin >> W >> H, W | H) {
    nb = 0;
    nw = 0;
    n = 0;
    flag = 1;
    flag2 = 0;
    for (int i = 0; i < H; i++) {
      cin >> field[i];
    }
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (field[i][j] == '.') {
          nb += umerub(j, i) * flag * flag2;
          flag = 1;
          flag2 = 0;
          n = 0;
          nw += umeruw(j, i) * flag * flag2;
          flag = 1;
          flag2 = 0;
          n = 0;
        }
      }
    }
    cout << nb << " " << nw << endl;
  }
  return 0;
}
