#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h;
  while (cin >> w >> h) {
    if (w == 0 && h == 0) {
      break;
    }
    vector<vector<char> > hyou(h, vector<char>(w));
    vector<vector<char> > hyou2(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> hyou[i][j];
        hyou2[i][j] = hyou[i][j];
      }
    }
    queue<pair<int, int> > q;
    queue<pair<int, int> > q2;
    queue<pair<int, int> > q3;
    queue<pair<int, int> > q4;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (hyou[i][j] == 'B') {
          pair<int, int> p;
          p.first = i;
          p.second = j;
          q.push(p);
          q4.push(p);
        }
        if (hyou[i][j] == 'W') {
          pair<int, int> p;
          p.first = i;
          p.second = j;
          q2.push(p);
          q3.push(p);
        }
      }
    }
    int di[] = {1, 0, -1, 0};
    int dj[] = {0, 1, 0, -1};
    while (!q.empty()) {
      pair<int, int> pp = q.front();
      q.pop();
      for (int i = 0; i < 4; i++) {
        if (pp.first + di[i] >= 0 && pp.first + di[i] < h &&
            pp.second + dj[i] >= 0 && pp.second + dj[i] < w &&
            hyou[pp.first + di[i]][pp.second + dj[i]] == '.') {
          hyou[pp.first + di[i]][pp.second + dj[i]] = 'B';
          pp.first += di[i];
          pp.second += dj[i];
          q.push(pp);
        }
      }
    }
    while (!q2.empty()) {
      pair<int, int> pp = q2.front();
      q2.pop();
      for (int i = 0; i < 4; i++) {
        if (pp.first + di[i] >= 0 && pp.first + di[i] < h &&
            pp.second + dj[i] >= 0 && pp.second + dj[i] < w &&
            hyou2[pp.first + di[i]][pp.second + dj[i]] == '.') {
          hyou2[pp.first + di[i]][pp.second + dj[i]] = 'W';
          pp.first += di[i];
          pp.second += dj[i];
          q2.push(pp);
        }
      }
    }
    int counter = 0;
    while (!q3.empty()) {
      pair<int, int> pp = q3.front();
      q3.pop();
      for (int i = 0; i < 4; i++) {
        if (pp.first + di[i] >= 0 && pp.first + di[i] < h &&
            pp.second + dj[i] >= 0 && pp.second + dj[i] < w &&
            hyou[pp.first + di[i]][pp.second + dj[i]] == '.') {
          hyou[pp.first + di[i]][pp.second + dj[i]] = 'W';
          pp.first += di[i];
          pp.second += dj[i];
          counter++;
          q3.push(pp);
        }
      }
    }
    int counter2 = 0;
    while (!q4.empty()) {
      pair<int, int> pp = q4.front();
      q4.pop();
      for (int i = 0; i < 4; i++) {
        if (pp.first + di[i] >= 0 && pp.first + di[i] < h &&
            pp.second + dj[i] >= 0 && pp.second + dj[i] < w &&
            hyou2[pp.first + di[i]][pp.second + dj[i]] == '.') {
          hyou2[pp.first + di[i]][pp.second + dj[i]] = 'B';
          pp.first += di[i];
          pp.second += dj[i];
          counter2++;
          q4.push(pp);
        }
      }
    }
    cout << counter2 << ' ' << counter << endl;
  }
  return 0;
}
