#include <bits/stdc++.h>
using namespace std;
int A[60][60];
int B[60][60];
int x, y;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
int dfs(int x, int y) {
  A[x][y] = 3;
  int ans = 0;
  for (int(i) = 0; (i) < (int)(4); (i)++) {
    int xx = dx[i] + x;
    int yy = dy[i] + y;
    if (A[xx][yy] == 0) {
      ans += dfs(xx, yy);
    }
  }
  return ans + 1;
}
int dfs2(int x, int y) {
  B[x][y] = 3;
  int ans = 0;
  for (int(i) = 0; (i) < (int)(4); (i)++) {
    int xx = dx[i] + x;
    int yy = dy[i] + y;
    if (B[xx][yy] == 0) {
      ans += dfs2(xx, yy);
    }
  }
  return ans + 1;
}
int main() {
  int W, H;
  while (cin >> W >> H, W + H) {
    for (int(i) = 0; (i) < (int)(30); (i)++) {
      for (int(j) = 0; (j) < (int)(30); (j)++) {
        A[i][j] = 1;
        B[i][j] = 1;
      }
    }
    for (int(i) = 0; (i) < (int)(H); (i)++) {
      string s;
      cin >> s;
      for (int(j) = 0; (j) < (int)(W); (j)++) {
        if (s[j] == '.') {
          A[i + 1][j + 1] = 0;
          B[i + 1][j + 1] = 0;
        }
        if (s[j] == 'B') {
          A[i + 1][j + 1] = 2;
        }
        if (s[j] == 'W') {
          B[i + 1][j + 1] = 2;
        }
      }
    }
    for (int(i) = 0; (i) < (int)(H + 1); (i)++) {
      for (int(j) = 0; (j) < (int)(W + 1); (j)++) {
        if (A[i][j] == 2) {
          for (int(k) = 0; (k) < (int)(4); (k)++) {
            int x = i + dx[k];
            int y = j + dy[k];
            if (A[x][y] == 0) {
              dfs(x, y);
            }
          }
        }
      }
    }
    for (int(i) = 0; (i) < (int)(H + 1); (i)++) {
      for (int(j) = 0; (j) < (int)(W + 1); (j)++) {
        if (B[i][j] == 2) {
          for (int(k) = 0; (k) < (int)(4); (k)++) {
            int x = i + dx[k];
            int y = j + dy[k];
            if (B[x][y] == 0) {
              dfs2(x, y);
            }
          }
        }
      }
    }
    int w = 0;
    int b = 0;
    for (int(i) = 0; (i) < (int)(H + 1); (i)++) {
      for (int(j) = 0; (j) < (int)(W + 1); (j)++) {
        if (A[i][j] == 3 && B[i][j] != 3) b++;
        if (A[i][j] != 3 && B[i][j] == 3) w++;
      }
    }
    cout << b << " " << w << endl;
  }
  return 0;
}
