#include <bits/stdc++.h>
int dfs(std::vector<std::vector<char> > map, int w, int h, char other_color) {
  int dx[] = {0, 0, 1, -1};
  int dy[] = {1, -1, 0, 0};
  int first;
  int second;
  int total = 0;
  int count;
  bool check;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (map[i][j] == '.') {
        count = 0;
        check = true;
        std::stack<std::pair<int, int> > st;
        st.push(std::make_pair(i, j));
        while (1) {
          if (st.empty() == 1) {
            break;
          }
          first = st.top().first;
          second = st.top().second;
          st.pop();
          for (int k = 0; k < 4; k++) {
            if (map[first + dx[k]][second + dy[k]] == '.') {
              st.push(std::make_pair(first + dx[k], second + dy[k]));
              map[first + dx[k]][second + dy[k]] = '#';
              ++count;
            } else if (map[first + dx[k]][second + dy[k]] == other_color) {
              check = false;
            }
          }
        }
        if (check == true) {
          total += count;
        } else {
          check = true;
        }
      }
    }
  }
  return total;
}
int main(void) {
  int w;
  int h;
  std::cin >> w >> h;
  std::vector<std::vector<char> > map_b(h + 2, std::vector<char>(w + 2, 'B'));
  std::vector<std::vector<char> > map_w(h + 2, std::vector<char>(w + 2, 'W'));
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      std::cin >> map_b[i][j];
      map_w[i][j] = map_b[i][j];
    }
  }
  std::cout << dfs(map_b, w, h, 'W') << " " << dfs(map_w, w, h, 'B')
            << std::endl;
  return 0;
}
