#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
using ll = long long;
int main() {
  int w, h;
  while (cin >> w >> h, w) {
    vs f(h + 2, string(w + 2, '#'));
    bool isExist = true;
    for (int i = 0; i < h; i++) {
      cin >> f[i + 1];
      isExist &=
          count(f[i + 1].begin(), f[i + 1].end(), '.') == f[i + 1].length();
      f[i + 1] = "#" + f[i + 1] + "#";
    }
    if (isExist) {
      cout << "0 0" << endl;
      continue;
    }
    int ans;
    vs b;
    ans = 0;
    b = f;
    for (int y = 1; y < h + 1; y++)
      for (int x = 1; x < w + 1; x++) {
        if (b[y][x] == 'B') continue;
        b[y][x] = 'B';
        int isEnable = 1;
        stack<pii> bfs;
        bfs.emplace(y, x);
        while (!bfs.empty()) {
          auto p = bfs.top();
          bfs.pop();
          vi v = {1, 0, -1, 0, 1};
          for (int i = 0; i < 4; i++) {
            int ty = p.first, tx = p.second;
            switch (b[ty + v[i]][tx + v[i + 1]]) {
              case 'W':
                isEnable = -100000;
              case '.':
                isEnable++;
                bfs.emplace(ty + v[i], tx + v[i + 1]);
                b[ty + v[i]][tx + v[i + 1]] = 'B';
            }
          }
        }
        if (isEnable > 0) ans += isEnable;
      }
    cout << ans << " ";
    ans = 0;
    b = f;
    for (int y = 1; y < h + 1; y++)
      for (int x = 1; x < w + 1; x++) {
        if (b[y][x] == 'W') continue;
        b[y][x] = 'W';
        int isEnable = 1;
        stack<pii> bfs;
        bfs.emplace(y, x);
        while (!bfs.empty()) {
          auto p = bfs.top();
          bfs.pop();
          vi v = {1, 0, -1, 0, 1};
          for (int i = 0; i < 4; i++) {
            int ty = p.first, tx = p.second;
            switch (b[ty + v[i]][tx + v[i + 1]]) {
              case 'B':
                isEnable = -10000;
              case '.':
                isEnable++;
                bfs.emplace(ty + v[i], tx + v[i + 1]);
                b[ty + v[i]][tx + v[i + 1]] = 'W';
            }
          }
        }
        if (isEnable > 0) ans += isEnable;
      }
    cout << ans << endl;
  }
}
