#include <bits/stdc++.h>
const double PI = acos(-1);
const double ESP = 1e-10;
using namespace std;
int n, m;
int x[4] = {1, 0, -1, 0};
int y[4] = {0, 1, 0, -1};
int func(vector<string>& in, char d, int i, int j) {
  int ans = 0;
  for (int k = 0; k < 4; k++) {
    int x1 = i + x[k];
    int y1 = j + y[k];
    if (x1 < 0 || x1 >= n || y1 < 0 || y1 >= m) continue;
    if (in[x1][y1] != '.' && in[x1][y1] != '!' && in[x1][y1] != d)
      return -1000000;
    if (in[x1][y1] != '!' && in[x1][y1] == '.') {
      ans++;
      in[x1][y1] = '!';
      ans += func(in, d, x1, y1);
    }
  }
  return ans;
}
int main() {
  while (cin >> m >> n, n || m) {
    vector<string> in(n);
    for (int i = 0; i < n; i++) cin >> in[i];
    int ans1 = 0, ans2 = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (in[i][j] != '!' && (in[i][j] == 'W' || in[i][j] == 'B')) {
          for (int b = 0; b < 4; b++) {
            int ans = 0, tmp;
            int x1 = i + x[b], y1 = j + y[b];
            if (x1 < 0 || x1 >= n || y1 < 0 || y1 >= m) continue;
            if (in[x1][y1] == '.') {
              in[x1][y1] = '!';
              ans++;
              tmp = func(in, in[i][j], x1, y1);
            } else
              tmp = -1;
            if (tmp >= 0)
              ans += tmp;
            else
              ans = 0;
            if (in[i][j] == 'W')
              ans2 += ans;
            else
              ans1 += ans;
          }
        }
      }
    }
    cout << ans1 << " " << ans2 << endl;
  }
}
