#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int w, h;
  cin >> w >> h;
  vector<string> in(h);
  for (int i = 0; i < h; i++) {
    cin >> in[i];
  }
  int ans_w = 0, ans_b = 0;
  vector<vector<int>> vis(h, vector<int>(w));
  int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (vis[i][j] || in[i][j] != '.') continue;
      vis[i][j] = 1;
      int siz = 1;
      queue<pair<int, int>> que;
      que.push({i, j});
      int col[2] = {};
      while (que.size()) {
        auto cur = que.front();
        que.pop();
        for (int k = 0; k < 4; k++) {
          int x = cur.first + dx[k];
          int y = cur.second + dy[k];
          if (x < 0 || x >= h || y < 0 || y >= w || vis[x][y]) continue;
          if (in[x][y] == 'W') {
            col[0] = 1;
            continue;
          }
          if (in[x][y] == 'B') {
            col[1] = 1;
            continue;
          }
          vis[x][y]++;
          que.push({x, y});
          siz++;
        }
      }
      if (col[0] + col[1] == 2) continue;
      if (col[0] == 1) ans_w += siz;
      if (col[1] == 1) ans_b += siz;
    }
  }
  cout << ans_b << " " << ans_w << endl;
  return 0;
}
