#include <bits/stdc++.h>
using namespace std;
int h, w;
char field[100][100];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
bool used[100][100];
bool fw, fb;
void solve(int y, int x) {
  used[y][x] = 1;
  if (field[y][x] == 'W') {
    fw = 1;
    return;
  }
  if (field[y][x] == 'B') {
    fb = 1;
    return;
  }
  for (long long i = 0; i < (4); i++) {
    int ny = y + dy[i], nx = x + dx[i];
    if (ny >= 0 && ny < h && nx >= 0 && nx < w) {
      if (!used[ny][nx]) solve(ny, nx);
    }
  }
}
int main() {
  while (cin >> h >> w && h + w) {
    int wans = 0, bans = 0;
    for (long long i = 0; i < (h); i++)
      for (long long j = 0; j < (w); j++) cin >> field[i][j];
    for (long long i = 0; i < (h); i++) {
      for (long long j = 0; j < (w); j++) {
        fw = 0;
        fb = 0;
        for (long long k = 0; k < (100); k++) fill(used[k], used[k] + 100, 0);
        if (field[i][j] == '.') {
          solve(i, j);
        }
        if (fw && !fb) wans++;
        if (!fw && fb) bans++;
      }
    }
    cout << bans << " " << wans << endl;
  }
}
