#include <bits/stdc++.h>
using namespace std;
bool visit[55][55];
char island[55][55];
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, 1, 0, -1};
int w, h;
bool dfs(int cx, int cy, char kui) {
  visit[cy][cx] = true;
  for (int k = 0; k < (4); k++) {
    int ny = cy + dy[k];
    int nx = cx + dx[k];
    if (ny < 0 || nx < 0 || ny >= h || nx >= w || visit[ny][nx]) continue;
    if (island[ny][nx] == 'B' || island[ny][nx] == 'W') {
      if ((kui == 'W' && island[ny][nx] == 'B') ||
          (kui == 'B' && island[ny][nx] == 'W')) {
        return false;
      }
      continue;
    }
    if (dfs(nx, ny, kui)) {
      island[ny][nx] = (kui == 'W' ? 'w' : 'b');
    } else {
      island[ny][nx] = 'f';
    }
  }
  return true;
}
void dfs2(int cx, int cy) {
  island[cy][cx] = 'f';
  visit[cy][cx] = true;
  for (int k = 0; k < (4); k++) {
    int nx = cx + dx[k];
    int ny = cy + dy[k];
    if (nx < 0 || nx >= w || ny < 0 || ny >= h || visit[ny][nx] ||
        island[ny][nx] == 'W' || island[ny][nx] == 'B')
      continue;
    dfs2(nx, ny);
  }
}
int main() {
  while (scanf("%d %d", &w, &h) && w && h) {
    memset(visit, false, sizeof(visit));
    for (int i = 0; i < (h); i++) {
      for (int j = 0; j < (w); j++) {
        scanf(" %c", &island[i][j]);
      }
    }
    for (int y = 0; y < (h); y++) {
      for (int x = 0; x < (w); x++) {
        if (!visit[y][x] && (island[y][x] == 'W' || island[y][x] == 'B')) {
          dfs(x, y, island[y][x]);
        }
      }
    }
    memset(visit, false, sizeof(visit));
    for (int y = 0; y < (h); y++) {
      for (int x = 0; x < (w); x++) {
        if (!visit[y][x] && island[y][x] == 'f') {
          dfs2(x, y);
        }
      }
    }
    int W = 0, B = 0;
    for (int y = 0; y < (h); y++) {
      for (int x = 0; x < (w); x++) {
        if (island[y][x] == 'w')
          W++;
        else if (island[y][x] == 'b')
          B++;
      }
    }
    printf("%d %d\n", B, W);
  }
  return 0;
}
