#include <bits/stdc++.h>
using namespace std;
int a[50][50], b[2][50][50];
int w, h, k;
int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
bool isok(int i, int j) { return i >= 0 && i < h && j >= 0 && j < w; }
void dfs(int i, int j) {
  if (!a[i][j]) b[k - 1][i][j] = 1;
  for (int s = 0; s < 4; ++s) {
    int ii = i + dx[s], jj = j + dy[s];
    if (isok(ii, jj) && !b[k - 1][ii][jj] && !a[ii][jj]) {
      dfs(ii, jj);
    }
  }
}
int main(void) {
  while (cin >> w >> h && w) {
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        char c;
        cin >> c;
        if (c == 'B')
          a[i][j] = 1;
        else if (c == 'W')
          a[i][j] = 2;
        else
          a[i][j] = 0;
        b[0][i][j] = 0;
        b[1][i][j] = 0;
      }
    }
    k = 1;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (a[i][j] == 1) dfs(i, j);
      }
    }
    cout << endl;
    k = 2;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (a[i][j] == 2) dfs(i, j);
      }
    }
    int bl = 0, wh = 0;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        bl += (b[0][i][j] && !b[1][i][j]);
        wh += (b[1][i][j] && !b[0][i][j]);
      }
    }
    cout << bl << " " << wh << endl;
  }
  return 0;
}
