#include <bits/stdc++.h>
using namespace std;
int X[4] = {0, 0, -1, 1};
int Y[4] = {-1, 1, 0, 0};
int w, h;
int ans[50][50];
int bl[50][50];
int wh[50][50];
void black(int x, int y) {
  bl[x][y] = 1;
  for (int i = 0; i < 4; i++) {
    if (x + X[i] > -1 && x + X[i] < w && y + Y[i] > -1 && y + Y[i] < h) {
      if (ans[x + X[i]][y + Y[i]] == 0 && bl[x + X[i]][y + Y[i]] == 0) {
        black(x + X[i], y + Y[i]);
      }
    }
  }
}
int a(0);
void white(int x, int y) {
  wh[x][y] = 1;
  for (int i = 0; i < 4; i++) {
    if (x + X[i] > -1 && x + X[i] < w && y + Y[i] > -1 && y + Y[i] < h) {
      if (ans[x + X[i]][y + Y[i]] == 0 && wh[x + X[i]][y + Y[i]] == 0) {
        white(x + X[i], y + Y[i]);
      }
    }
  }
}
int main() {
  while (cin >> w >> h && !(w == 0 && h == 0)) {
    for (int i = 0; i < 51; i++) {
      for (int j = 0; j < 51; j++) {
        ans[j][i] = 0;
        bl[j][i] = 0;
        wh[j][i] = 0;
      }
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        char tmp;
        cin >> tmp;
        switch (tmp) {
          case 'B':
            ans[j][i] = 1;
            break;
          case 'W':
            ans[j][i] = 2;
            break;
        }
      }
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        int tmp1(false), tmp2(false);
        for (int k = 0; k < 4; k++) {
          if (j + X[k] > -1 && j + X[k] < w && i + Y[k] > -1 && i + Y[k] < h) {
            if (ans[j + X[k]][i + Y[k]] == 1) {
              tmp1 = true;
            }
            if (ans[j + X[k]][i + Y[k]] == 2) {
              tmp2 = true;
            }
          }
        }
        if (tmp1 && bl[j][i] != 1 && ans[j][i] == 0) {
          black(j, i);
        }
        if (tmp2 && wh[j][i] != 1 && ans[j][i] == 0) {
          white(j, i);
        }
      }
    }
    int ans1(0), ans2(0);
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (bl[j][i] + wh[j][i] == 2) {
          ;
        } else if (wh[j][i] == 1) {
          ans2++;
        } else if (bl[j][i] == 1) {
          ans1++;
        }
      }
    }
    cout << ans1 << " " << ans2 << endl;
  }
  return 0;
}
