#include <bits/stdc++.h>
using namespace std;
char ground[100][100] = {'*'};
void jin_w(int i, int j) {
  if (ground[i][j - 1] == '.') {
    ground[i][j - 1] = 'w';
    jin_w(i, j - 1);
  } else if (ground[i][j - 1] == 'b') {
    ground[i][j - 1] = '*';
    jin_w(i, j - 1);
  }
  if (ground[i + 1][j] == '.') {
    ground[i + 1][j] = 'w';
    jin_w(i + 1, j);
  } else if (ground[i + 1][j] == 'b') {
    ground[i + 1][j] = '*';
    jin_w(i + 1, j);
  }
  if (ground[i][j + 1] == '.') {
    ground[i][j + 1] = 'w';
    jin_w(i, j + 1);
  } else if (ground[i][j + 1] == 'b') {
    ground[i][j + 1] = '*';
    jin_w(i, j + 1);
  }
  if (ground[i - 1][j] == '.') {
    ground[i - 1][j] = 'w';
    jin_w(i - 1, j);
  } else if (ground[i - 1][j] == 'b') {
    ground[i - 1][j] = '*';
    jin_w(i - 1, j);
  }
}
void jin_b(int i, int j) {
  if (ground[i][j - 1] == '.') {
    ground[i][j - 1] = 'b';
    jin_b(i, j - 1);
  } else if (ground[i][j - 1] == 'w') {
    ground[i][j - 1] = '*';
    jin_b(i, j - 1);
  }
  if (ground[i + 1][j] == '.') {
    ground[i + 1][j] = 'b';
    jin_b(i + 1, j);
  } else if (ground[i + 1][j] == 'w') {
    ground[i + 1][j] = '*';
    jin_b(i + 1, j);
  }
  if (ground[i][j + 1] == '.') {
    ground[i][j + 1] = 'b';
    jin_b(i, j + 1);
  } else if (ground[i][j + 1] == 'w') {
    ground[i][j + 1] = '*';
    jin_b(i, j + 1);
  }
  if (ground[i - 1][j] == '.') {
    ground[i - 1][j] = 'b';
    jin_b(i - 1, j);
  } else if (ground[i - 1][j] == 'w') {
    ground[i - 1][j] = '*';
    jin_b(i - 1, j);
  }
}
int main() {
  int w, h;
  while (cin >> w >> h, w, h) {
    int cnt_w = 0;
    int cnt_b = 0;
    for (int i = 1; i < h + 1; ++i) {
      for (int j = 1; j < w + 1; ++j) {
        cin >> ground[i][j];
      }
    }
    for (int i = 1; i < h + 1; ++i) {
      for (int j = 1; j < w + 1; ++j) {
        if (ground[i][j] == 'W')
          jin_w(i, j);
        else if (ground[i][j] == 'B')
          jin_b(i, j);
      }
    }
    for (int i = 1; i < h + 1; ++i) {
      for (int j = 1; j < w + 1; ++j) {
        if (ground[i][j] == 'w')
          cnt_w++;
        else if (ground[i][j] == 'b')
          cnt_b++;
      }
    }
    cout << cnt_b << ' ' << cnt_w << endl;
  }
}
