#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline bool cheak(int x, int y, int xMax, int yMax) {
  return x >= 0 && y >= 0 && xMax > x && yMax > y;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1},
          dy[8] = {0, -1, 0, 1, -1, 1, -1, 1};
const int mod = 1000000007;
const int INF = 1e9;
const int M = 51;
char c[M][M];
char d[M][M];
int w, h;
bool f[M][M];
char dfs(int y, int x) {
  if (c[y][x] != '.') return c[y][x];
  if (d[y][x]) return 0;
  f[y][x] = true;
  char ret = -1;
  for (int(i) = (0); i < (4); (i)++) {
    int tx = x + dx[i], ty = y + dy[i];
    if (cheak(tx, ty, w, h) && !f[ty][tx]) {
      char t = dfs(ty, tx);
      if (ret == -1 || t == ret) {
        ret = t;
      } else {
        ret = 0;
      }
    }
  }
  return ret;
}
void sdfs(int y, int x, char n) {
  if (n == 0) return;
  f[y][x] = false;
  d[y][x] = n;
  for (int(i) = (0); i < (4); (i)++) {
    int tx = x + dx[i], ty = y + dy[i];
    if (cheak(tx, ty, w, h) && f[ty][tx]) {
      sdfs(ty, tx, n);
    }
  }
}
int main() {
  while (cin >> w >> h && w) {
    memset((d), 0, sizeof(d));
    for (int(y) = (0); y < (h); (y)++)
      for (int(x) = (0); x < (w); (x)++) {
        cin >> c[y][x];
      }
    for (int(y) = (0); y < (h); (y)++)
      for (int(x) = (0); x < (w); (x)++) {
        memset((f), 0, sizeof(f));
        sdfs(y, x, dfs(y, x));
      }
    int ba = 0, wa = 0;
    for (int(y) = (0); y < (h); (y)++)
      for (int(x) = (0); x < (w); (x)++) {
        if (c[y][x] == '.') {
          if (d[y][x] == 'B') ba++;
          if (d[y][x] == 'W') wa++;
        }
      }
    cout << ba << " " << wa << endl;
  }
  return 0;
}
