#include <bits/stdc++.h>
using namespace std;
static const double PI = 6 * asin(0.5);
static const int INF = 1 << 24;
template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}
vector<vector<int> > vv;
vector<vector<int> > vis;
int B, W;
int x, y;
bool f1, f2;
int foo(int a, int b) {
  int ret = 0;
  if (vv[a][b] == 1) f1 = true;
  if (vv[a][b] == 2) f2 = true;
  if (vis[a][b]) return 0;
  vis[a][b] = 1;
  ret++;
  if (a > 0) {
    ret += foo(a - 1, b);
  }
  if (a < x - 1) {
    ret += foo(a + 1, b);
  }
  if (b > 0) {
    ret += foo(a, b - 1);
  }
  if (b < y - 1) {
    ret += foo(a, b + 1);
  }
  return ret;
}
int main() {
  while (cin >> x >> y, x || y) {
    initvv(vv, x, y);
    initvv(vis, x, y);
    B = 0;
    W = 0;
    for (int(i) = (0); (i) < ((x)); ++(i)) {
      for (int(j) = (0); (j) < ((y)); ++(j)) {
        vis[i][j] = 0;
        char t;
        cin >> t;
        if (t == 'B') {
          vv[i][j] = 1;
          vis[i][j] = 1;
        } else if (t == '.') {
          vv[i][j] = 0;
        } else {
          vv[i][j] = 2;
          vis[i][j] = 1;
        }
      }
    }
    for (int(i) = (0); (i) < ((x)); ++(i)) {
      for (int(j) = (0); (j) < ((y)); ++(j)) {
        if (vis[i][j] == 0) {
          f1 = false;
          f2 = false;
          int tt = foo(i, j);
          if (f1 && !f2) {
            B += tt;
          }
          if (!f1 && f2) {
            W += tt;
          }
        }
      }
    }
    cout << B << " " << W << endl;
  }
  return 0;
}
