#include <bits/stdc++.h>
using namespace std;
int w, h;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
string f[51];
void solve(int x, int y, char c) {
  for (int i = 0; i < 4; i++) {
    int mx = x + dx[i];
    int my = y + dy[i];
    if (mx < 0 || mx > w || my < 0 || my > h) continue;
    if (f[my][mx] == '.') {
      f[my][mx] = (c == 'W') ? 'w' : 'b';
      solve(mx, my, c);
    } else if (c == 'B' && f[my][mx] == 'w') {
      f[my][mx] = '?';
      solve(mx, my, 'B');
    }
  }
}
int main() {
  while (cin >> w >> h, w || h) {
    int white = 0, black = 0;
    for (int i = 0; i < h; i++) {
      cin >> f[i];
    }
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        if (f[y][x] == 'W') {
          solve(x, y, 'W');
        }
      }
    }
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        if (f[y][x] == 'B') {
          solve(x, y, 'B');
        }
      }
    }
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        if (f[y][x] == 'b') {
          black++;
        } else if (f[y][x] == 'w') {
          white++;
        }
      }
    }
    cout << black << " " << white << endl;
  }
}
