#include <bits/stdc++.h>
using namespace std;
char area[10][10];
int ans[10][10];
int visit[10][10];
int W, H;
void init() {
  fill_n((char *)area, sizeof(area) / sizeof(char), '.');
  fill_n((int *)ans, sizeof(ans) / sizeof(int), 0);
  fill_n((int *)visit, sizeof(visit) / sizeof(int), 0);
}
void clear() { fill_n((int *)visit, sizeof(visit) / sizeof(int), 0); }
void dfs(int x, int y, char color) {
  int mark = (color == 'W') ? 1 : 2;
  char rival = (color == 'W') ? 'B' : 'W';
  int dx[4] = {1, 0, -1, 0};
  int dy[4] = {0, 1, 0, -1};
  if (x < 0 || x >= W || y < 0 || y >= H) {
    return;
  }
  if (area[y][x] == rival) {
    return;
  }
  if (!visit[y][x]) {
    visit[y][x] = 1;
    if (area[y][x] != 'W' && area[y][x] != 'B') {
      ans[y][x] |= mark;
    }
    for (int i = 0; i < (int)(4); ++i) {
      dfs(x + dx[i], y + dy[i], color);
    }
  }
  return;
}
int main() {
  while (cin >> W >> H && W) {
    int black = 0, white = 0;
    init();
    for (int h = 0; h < (int)(H); ++h) {
      for (int w = 0; w < (int)(W); ++w) {
        cin >> area[h][w];
      }
    }
    for (int h = 0; h < (int)(H); ++h) {
      for (int w = 0; w < (int)(W); ++w) {
        if (area[h][w] != '.') {
          clear();
          dfs(w, h, area[h][w]);
        }
      }
    }
    for (int h = 0; h < (int)(H); ++h) {
      for (int w = 0; w < (int)(W); ++w) {
        int num = ans[h][w];
        if (num == 1) {
          white++;
        }
        if (num == 2) {
          black++;
        }
      }
    }
    cout << black << " " << white << endl;
  }
  return 0;
}
