#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int W, H;
char A[80][80];
int dd[5] = { 0, 1, 0, -1, 0 };
bool v[80][80], s[2][80][80];

bool isin(int y, int x) { return 0 <= y && y < H && 0 <= x && x < W; }

void dfs(int y, int x, int c) {
  if(v[y][x] || A[y][x] != '.') return;
  v[y][x] = true;
  s[c][y][x] = true;
  REP(i, 0, 4) if(isin(y + dd[i], x + dd[i + 1])) dfs(y + dd[i], x + dd[i + 1], c);
}

int main(void) {
  while(cin >> W >> H, W || H) {
    REP(i, 0, H) cin >> A[i];

    REP(i, 0, 2) REP(j, 0, H) REP(k, 0, W) s[i][j][k] = false;
    REP(i, 0, H) REP(j, 0, W) if(A[i][j] != '.') {
      REP(k, 0, 4) if(isin(i + dd[k], j + dd[k + 1])) {
        REP(l, 0, H) REP(m, 0, W) v[l][m] = false;
        dfs(i + dd[k], j + dd[k + 1], A[i][j] == 'W');
      }
    }

    int ans[2] = { 0, 0 };
    REP(i, 0, 2) REP(j, 0, H) REP(k, 0, W) if(s[i][j][k] && !s[1 - i][j][k]) ans[i]++;
    cout << ans[0] << " " << ans[1] << endl;
  }
  return 0;
}