#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 x, int y) {
  n++;
  field[y][x] = 'X';
  if (y != 0 && field[y - 1][x] == '.') umerub(x, y - 1);
  if (x != 0 && field[y][x - 1] == '.') umerub(x - 1, y);
  if (y != H - 1 && field[y + 1][x] == '.') umerub(x, y + 1);
  if (x != W - 1 && field[y][x + 1] == '.') umerub(x + 1, y);
  if (y != 0 && field[y - 1][x] == 'W') flag = 0;
  if (x != 0 && field[y][x - 1] == 'W') flag = 0;
  if (y != H - 1 && field[y + 1][x] == 'W') flag = 0;
  if (x != W - 1 && field[y][x + 1] == 'W') flag = 0;
  if (y != 0 && field[y - 1][x] == 'B') flag2 = 1;
  if (x != 0 && field[y][x - 1] == 'B') flag2 = 1;
  if (y != H - 1 && field[y + 1][x] == 'B') flag2 = 1;
  if (x != W - 1 && field[y][x + 1] == 'B') flag2 = 1;
  return n;
}
int umeruw(int x, int y) {
  n++;
  field[y][x] = 'W';
  if (y != 0 && field[y - 1][x] == 'X') umeruw(x, y - 1);
  if (x != 0 && field[y][x - 1] == 'X') umeruw(x - 1, y);
  if (y != H - 1 && field[y + 1][x] == 'X') umeruw(x, y + 1);
  if (x != W - 1 && field[y][x + 1] == 'X') umeruw(x + 1, y);
  if (y != 0 && field[y - 1][x] == 'B') flag = 0;
  if (x != 0 && field[y][x - 1] == 'B') flag = 0;
  if (y != H - 1 && field[y + 1][x] == 'B') flag = 0;
  if (x != W - 1 && field[y][x + 1] == 'B') flag = 0;
  if (y != 0 && field[y - 1][x] == 'W') flag2 = 1;
  if (x != 0 && field[y][x - 1] == 'W') flag2 = 1;
  if (y != H - 1 && field[y + 1][x] == 'W') flag2 = 1;
  if (x != W - 1 && field[y][x + 1] == 'W') flag2 = 1;
  return n;
}
int main() {
  while (cin >> W >> H, W | H) {
    nb = 0;
    nw = 0;
    n = 0;
    flag = 1;
    flag2 = 0;
    fill_n((char *)field, 50 * 50, 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;
}
