#include <bits/stdc++.h>
using namespace std;
static const double PI = acos(-1.0);
static const double EPS = 1e-10;
inline int onbits_count(unsigned long long int b) {
  int c = 0;
  while (b != 0) {
    c += (b & 1);
    b >>= 1;
  }
  return c;
}
inline int bits_count(unsigned long long int b) {
  int c = 0;
  while (b != 0) {
    ++c;
    b >>= 1;
  }
  return c;
}
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
inline double now() {
  struct timeval tv;
  gettimeofday(&tv, NULL);
  return (static_cast<double>(tv.tv_sec) +
          static_cast<double>(tv.tv_usec) * 1e-6);
}
inline vector<string> split(string s, char delimiter) {
  vector<string> v;
  string t;
  for (typeof(s.length()) i = (0); i != (s.length());
       i < (s.length()) ? ++i : --i) {
    if (s[i] == delimiter)
      v.push_back(t), t = "";
    else
      t += s[i];
  }
  v.push_back(t);
  return v;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& s, const pair<T1, T2>& d) {
  return s << "(" << d.first << ", " << d.second << ")";
}
int n_dir = 4;
int dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0};
enum direction { UP, RIGHT, DOWN, LEFT };
int w, h;
vector<vector<char> > field;
vector<vector<bool> > adj_white;
vector<vector<bool> > adj_black;
void spread(char color, int sy, int sx) {
  vector<vector<bool> > visited =
      vector<vector<bool> >(h, vector<bool>(w, false));
  queue<pair<int, int> > q;
  q.push(make_pair(sy, sx));
  while (!q.empty()) {
    int y = q.front().first, x = q.front().second;
    q.pop();
    visited[y][x] = true;
    if (color == 'W') {
      adj_white[y][x] = true;
    } else {
      adj_black[y][x] = true;
    }
    for (typeof(4) d = (0); d != (4); d < (4) ? ++d : --d) {
      int ny = y + dy[d], nx = x + dx[d];
      if (!(0 <= ny && ny < h) || !(0 <= nx && nx < w)) continue;
      ;
      if (!visited[ny][nx] && field[ny][nx] == '.') {
        q.push(make_pair(ny, nx));
      }
    }
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  while (cin >> w >> h, w | h) {
    field = vector<vector<char> >(h, vector<char>(w));
    for (typeof(h) i = (0); i != (h); i < (h) ? ++i : --i) {
      for (typeof(w) j = (0); j != (w); j < (w) ? ++j : --j) {
        cin >> field[i][j];
      }
    }
    adj_black = vector<vector<bool> >(h, vector<bool>(w, false));
    adj_white = vector<vector<bool> >(h, vector<bool>(w, false));
    for (typeof(h) i = (0); i != (h); i < (h) ? ++i : --i) {
      for (typeof(w) j = (0); j != (w); j < (w) ? ++j : --j) {
        if (field[i][j] != '.') {
          spread(field[i][j], i, j);
        }
      }
    }
    int white = 0, black = 0;
    for (typeof(h) i = (0); i != (h); i < (h) ? ++i : --i) {
      for (typeof(w) j = (0); j != (w); j < (w) ? ++j : --j) {
        if (field[i][j] == '.') {
          if (adj_white[i][j] && !adj_black[i][j]) {
            ++white;
          }
          if (!adj_white[i][j] && adj_black[i][j]) {
            ++black;
          }
        }
      }
    }
    cout << black << " " << white << endl;
  }
}
