#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h;
  while (cin >> w >> h, w || h) {
    vector<int> tt(h, 0);
    vector<vector<int> > vv(w, tt);
    vector<vector<int> > table = vv;
    int v[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};
    for (int i = 0; i < w; i++) {
      for (int j = 0; j < h; j++) {
        char t;
        cin >> t;
        if (t == '.')
          vv[i][j] = 0;
        else if (t == 'W') {
          vv[i][j] = 1;
          table[i][j] = -1;
        } else {
          vv[i][j] = 2;
          table[i][j] = -1;
        }
      }
    }
    for (int i = 0; i < w; i++) {
      for (int j = 0; j < h; j++) {
        if (vv[i][j] == 0)
          continue;
        else {
          queue<pair<int, int> > q;
          q.push(make_pair(i, j));
          while (!q.empty()) {
            pair<int, int> t = q.front();
            q.pop();
            for (int k = 0; k < 4; k++) {
              int x = t.first + v[k][0], y = t.second + v[k][1];
              if (x >= 0 && y >= 0 && x < w && y < h) {
                if (table[x][y] == 0 || table[x][y] == 3 - vv[i][j]) {
                  table[x][y] += vv[i][j];
                  q.push(make_pair(x, y));
                }
              }
            }
          }
        }
      }
    }
    int answ = 0, ansb = 0;
    for (int i = 0; i < w; i++) {
      for (int j = 0; j < h; j++) {
        if (table[i][j] == 1) {
          answ++;
        } else if (table[i][j] == 2) {
          ansb++;
        }
      }
    }
    cout << ansb << " " << answ << endl;
  }
  return 0;
}
