#include <bits/stdc++.h>
using namespace std;
int w, h;
char F[52][52][2];
int check(int x, int y, char a, int wb) {
  if (F[x - 1][y][wb] == '.') {
    F[x - 1][y][wb] = a;
    check(x - 1, y, a, wb);
  }
  if (F[x + 1][y][wb] == '.') {
    F[x + 1][y][wb] = a;
    check(x + 1, y, a, wb);
  }
  if (F[x][y - 1][wb] == '.') {
    F[x][y - 1][wb] = a;
    check(x, y - 1, a, wb);
  }
  if (F[x][y + 1][wb] == '.') {
    F[x][y + 1][wb] = a;
    check(x, y + 1, a, wb);
  }
}
int main() {
  int flag;
  int nw, nb;
  char a, b;
  while (cin >> w >> h && w && h) {
    nw = 0;
    nb = 0;
    for (int j = 1; j <= h; ++j) {
      for (int i = 1; i <= w; ++i) {
        cin >> F[i][j][0];
        F[i][j][1] = F[i][j][0];
      }
    }
    for (int k = 0; k < 2; ++k) {
      if (k == 0) a = 'w', b = 'W';
      if (k == 1) a = 'b', b = 'B';
      for (int j = 1; j <= h; ++j) {
        for (int i = 1; i <= w; ++i) {
          if (F[i][j][k] == b) check(i, j, a, k);
        }
      }
    }
    for (int j = 1; j <= h; ++j) {
      for (int i = 1; i <= w; ++i) {
        if (F[i][j][0] == 'w' && F[i][j][1] == '.')
          ++nw;
        else if (F[i][j][1] == 'b' && F[i][j][0] == '.')
          ++nb;
      }
    }
    cout << nb << " " << nw << endl;
  }
}
