#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, cost;
};
void begin() {
  cin.tie(0);
  ios::sync_with_stdio(false);
};
int gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
};
int lcm(int m, int n) {
  if ((0 == m) || (0 == n)) {
    return 0;
  }
  return ((m / gcd(m, n)) * n);
};
unsigned long long comb(long n, long m) {
  if (n < m) return 0;
  unsigned long long c = 1;
  m = (n - m < m ? n - m : m);
  for (long ns = n - m + 1, ms = 1; ms <= m; ns++, ms++) {
    c *= ns;
    c /= ms;
  }
  return c;
};
int quadratic(int a, int b, int c) {
  return (int)(-b + sqrt(b * b - 4 * a * c)) / 2 * a;
}
void cp(int a1[], int a2[], int l) {
  for (int i = 0; i < l; i++) a2[i] = a1[i];
};
void cp(string a1[], string a2[], int l) {
  for (int i = 0; i < l; i++) a2[i] = a1[i];
};
double sq(double d) { return d * d; };
int sq(int i) { return i * i; };
double sqdist(int x1, int y1, int x2, int y2) {
  double dx = x1 - x2, dy = y1 - y2;
  return dx * dx + dy * dy;
};
bool inside(int y, int x, int h, int w) {
  return 0 <= y && y <= (h - 1) && 0 <= x && x <= (w - 1);
};
bool isCross(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
  int m = (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3);
  if (m == 0) return false;
  double r = (double)((y4 - y3) * (x3 - x1) - (x4 - x3) * (y3 - y1)) / m;
  double s = (double)((y2 - y1) * (x3 - x1) - (x2 - x1) * (y3 - y1)) / m;
  return (0 < r && r <= 1 && 0 < s && s <= 1);
};
int crossProdct(int ax, int ay, int bx, int by, int cx, int cy, int dx,
                int dy) {
  int abx = bx - ax;
  int aby = by - ay;
  int cdx = dx - cx;
  int cdy = dy - cy;
  return abx * cdy - cdx * aby;
};
double crossProdct(double ax, double ay, double bx, double by, double cx,
                   double cy, double dx, double dy) {
  double abx = bx - ax;
  double aby = by - ay;
  double cdx = dx - cx;
  double cdy = dy - cy;
  return abx * cdy - cdx * aby;
};
double innerProduct(double ax, double ay, double bx, double by, double cx,
                    double cy, double dx, double dy) {
  double abx = bx - ax;
  double aby = by - ay;
  double cdx = dx - cx;
  double cdy = dy - cy;
  return abx * cdx + aby * cdy;
};
bool inTriangle(int ax, int ay, int bx, int by, int cx, int cy, int px,
                int py) {
  int c1 = crossProdct(ax, ay, bx, by, bx, by, px, py);
  int c2 = crossProdct(bx, by, cx, cy, cx, cy, px, py);
  int c3 = crossProdct(cx, cy, ax, ay, ax, ay, px, py);
  return (c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0);
};
bool inTriangle(double ax, double ay, double bx, double by, double cx,
                double cy, double px, double py) {
  double c1 = crossProdct(ax, ay, bx, by, bx, by, px, py);
  double c2 = crossProdct(bx, by, cx, cy, cx, cy, px, py);
  double c3 = crossProdct(cx, cy, ax, ay, ax, ay, px, py);
  return (c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0);
};
void circumcenter(double x1, double y1, double x2, double y2, double x3,
                  double y3, double res[3]) {
  double xp1 = (y1 - y3) * (y1 * y1 - y2 * y2 + x1 * x1 - x2 * x2) -
               (y1 - y2) * (y1 * y1 - y3 * y3 + x1 * x1 - x3 * x3);
  double xp2 = 2 * (y1 - y3) * (x1 - x2) - 2 * (y1 - y2) * (x1 - x3);
  res[0] = xp1 / xp2;
  double yp1 = (x1 - x3) * (x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2) -
               (x1 - x2) * (x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3);
  double yp2 = 2 * (x1 - x3) * (y1 - y2) - 2 * (x1 - x2) * (y1 - y3);
  res[1] = yp1 / yp2;
  double r = (x3 - res[0]) * (x3 - res[0]) + (y3 - res[1]) * (y3 - res[1]);
  res[2] = sqrt(r);
}
void cal() {
  string week[7] = {"Thursday", "Friday",  "Saturday", "Sunday",
                    "Monday",   "Tuesday", "Wednesday"};
  int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  vector<string> cal[12];
  int counter = 0;
  for (int i = 0; i < 12; i++)
    for (int j = 0; j < month[i]; j++) {
      cal[i].push_back(week[counter % 7]);
      counter++;
    }
}
class BinaryIndexedTree {
 public:
  int n;
  vector<int> bit;
  BinaryIndexedTree(int _n) {
    n = _n;
    bit.resize(n + 1, 0);
  }
  int sum(int i) {
    int sum = 0;
    while (i > 0) {
      sum += bit[i];
      i -= i & -i;
    }
    return sum;
  }
  void add(int i, int v) {
    while (i <= n) {
      bit[i] += v;
      i += i & -i;
    }
  }
};
class UnionFindTree {
 public:
  vector<int> parent, rank;
  int n;
  std::set<int> set;
  UnionFindTree(int _n) {
    n = _n;
    for (int i = 0; i < n; i++) {
      parent.resize(n);
      rank.resize(n);
      parent[i] = i;
      rank[i] = 0;
    }
  }
  int find(int x) {
    if (parent[x] == x) {
      return x;
    } else {
      return parent[x] = find(parent[x]);
    }
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
      set.insert(x);
      return;
    }
    if (rank[x] < rank[y]) {
      parent[x] = y;
      set.erase(x);
      set.insert(y);
    } else {
      parent[y] = x;
      set.erase(y);
      set.insert(x);
      if (rank[x] == rank[y]) rank[x]++;
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int count() { return (int)set.size(); }
};
void warshallFloyd(int graph[100][100], int graph_size) {
  for (int mid_node = 0; mid_node < graph_size; mid_node++)
    for (int s_node = 0; s_node < graph_size; s_node++)
      for (int g_node = 0; g_node < graph_size; g_node++)
        if (s_node == g_node)
          graph[s_node][g_node] = 0;
        else
          graph[s_node][g_node] =
              min(graph[s_node][g_node],
                  graph[s_node][mid_node] + graph[mid_node][g_node]);
};
void dijkstra(int graph[1000][1000], int node_count, int start_node,
              int distances[1000]) {
  for (int i = 0; i < node_count; i++) distances[i] = -1;
  distances[start_node] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      dijkstra_pq;
  dijkstra_pq.push(pair<int, int>(0, start_node));
  while (!dijkstra_pq.empty()) {
    pair<int, int> p = dijkstra_pq.top();
    dijkstra_pq.pop();
    int i = p.second;
    if (distances[i] < p.first) continue;
    for (int j = 0; j < node_count; j++) {
      if (graph[i][j] == -1) continue;
      if (distances[j] == -1) {
        distances[j] = distances[i] + graph[i][j];
        dijkstra_pq.push(pair<int, int>(distances[j], j));
      } else if (distances[j] > distances[i] + graph[i][j]) {
        distances[j] = distances[i] + graph[i][j];
        dijkstra_pq.push(pair<int, int>(distances[j], j));
      }
    }
  }
};
string area[50];
int color[50][50][2];
int vi[4] = {-1, 1, 0, 0}, vj[4] = {0, 0, -1, 1};
void dfs(int i, int j, int r, int c, int side) {
  for (int k = 0; k < 4; k++) {
    int ni = i + vi[k];
    int nj = j + vj[k];
    if (inside(ni, nj, r, c) && area[ni][nj] == '.' && !color[ni][nj][side]) {
      color[ni][nj][side] = 1;
      dfs(ni, nj, r, c, side);
    }
  }
};
int main(int argc, const char* argv[]) {
  int r, c;
  cin >> c >> r;
  for (int i = 0; i < r; i++) cin >> area[i];
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++) {
      color[i][j][0] = 0;
      color[i][j][1] = 0;
    }
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++) {
      if (area[i][j] == 'B') {
        dfs(i, j, r, c, 0);
      } else if (area[i][j] == 'W') {
        dfs(i, j, r, c, 1);
      }
    }
  int black = 0, white = 0;
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++) {
      if (color[i][j][0] && !color[i][j][1]) {
        black++;
      } else if (!color[i][j][0] && color[i][j][1]) {
        white++;
      }
    }
  cout << black << " " << white << endl;
}
