#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h;
  while (cin >> w >> h) {
    if (w == 0 && h == 0) break;
    int k[w + 2][h + 2], s[w + 2][h + 2], nk = 0, ns = 0;
    for (int i = 0; i <= h + 1; i++) {
      k[0][i] = 1;
      k[w + 1][i] = 1;
      s[0][i] = 1;
      s[w + 1][i] = 1;
    }
    for (int i = 1; i <= w; i++) {
      k[i][0] = 1;
      k[i][h + 1] = 1;
      s[i][0] = 1;
      s[i][h + 1] = 1;
    }
    string str;
    for (int i = 1; i <= h; i++) {
      cin >> str;
      for (int j = 1; j <= w; j++) {
        if (str[j - 1] == '.') {
          k[j][i] = 0;
          s[j][i] = 0;
          nk++;
          ns++;
        } else if (str[j - 1] == 'B') {
          k[j][i] = 2;
          s[j][i] = 2;
        } else if (str[j - 1] == 'W') {
          k[j][i] = 3;
          s[j][i] = 3;
        }
      }
    }
    int ct = 1;
    while (nk > 0) {
      for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
          if (k[j][i] == 0) {
            k[j][i] = 6;
            nk--;
            goto e1;
          }
        }
      }
    e1:;
      int ckk = 0, cks = 0;
      ct = 1;
      while (ct > 0) {
        ct = 0;
        for (int i = 1; i <= h; i++) {
          for (int j = 1; j <= w; j++) {
            if (k[j][i] == 6) {
              if (k[j + 1][i] == 0) {
                k[j + 1][i] = 6;
                nk--;
                ct++;
              } else if (k[j - 1][i] == 0) {
                k[j - 1][i] = 6;
                nk--;
                ct++;
              } else if (k[j][i + 1] == 0) {
                k[j][i + 1] = 6;
                nk--;
                ct++;
              } else if (k[j][i - 1] == 0) {
                k[j][i - 1] = 6;
                nk--;
                ct++;
              } else if (k[j + 1][i] == 2)
                ckk++;
              else if (k[j - 1][i] == 2)
                ckk++;
              else if (k[j][i + 1] == 2)
                ckk++;
              else if (k[j][i - 1] == 2)
                ckk++;
              else if (k[j + 1][i] == 3)
                cks++;
              else if (k[j - 1][i] == 3)
                cks++;
              else if (k[j][i + 1] == 3)
                cks++;
              else if (k[j][i - 1] == 3)
                cks++;
            }
          }
        }
      }
      if (cks > 0 || ckk == 0) {
        for (int i = 1; i <= h; i++) {
          for (int j = 1; j <= w; j++) {
            if (k[j][i] == 6) k[j][i] = 5;
          }
        }
      } else {
        for (int i = 1; i <= h; i++) {
          for (int j = 1; j <= w; j++) {
            if (k[j][i] == 6) k[j][i] = 4;
          }
        }
      }
    }
    ct = 1;
    while (ns > 0) {
      for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
          if (s[j][i] == 0) {
            s[j][i] = 6;
            ns--;
            goto e2;
          }
        }
      }
    e2:;
      int csk = 0, css = 0;
      ct = 1;
      while (ct > 0) {
        ct = 0;
        for (int i = 1; i <= h; i++) {
          for (int j = 1; j <= w; j++) {
            if (s[j][i] == 6) {
              if (s[j + 1][i] == 0) {
                s[j + 1][i] = 6;
                ns--;
                ct++;
              } else if (s[j - 1][i] == 0) {
                s[j - 1][i] = 6;
                ns--;
                ct++;
              } else if (s[j][i + 1] == 0) {
                s[j][i + 1] = 6;
                ns--;
                ct++;
              } else if (s[j][i - 1] == 0) {
                s[j][i - 1] = 6;
                ns--;
                ct++;
              } else if (s[j + 1][i] == 2)
                csk++;
              else if (s[j - 1][i] == 2)
                csk++;
              else if (s[j][i + 1] == 2)
                csk++;
              else if (s[j][i - 1] == 2)
                csk++;
              else if (s[j + 1][i] == 3)
                css++;
              else if (s[j - 1][i] == 3)
                css++;
              else if (s[j][i + 1] == 3)
                css++;
              else if (s[j][i - 1] == 3)
                css++;
            }
          }
        }
      }
      if (csk > 0 || css == 0) {
        for (int i = 1; i <= h; i++) {
          for (int j = 1; j <= w; j++) {
            if (s[j][i] == 6) s[j][i] = 5;
          }
        }
      } else {
        for (int i = 1; i <= h; i++) {
          for (int j = 1; j <= w; j++) {
            if (s[j][i] == 6) s[j][i] = 4;
          }
        }
      }
    }
    int kazub = 0, kazuw = 0;
    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        if (k[j][i] == 4) kazub++;
        if (s[j][i] == 4) kazuw++;
      }
    }
    cout << kazub << " " << kazuw << endl;
  }
  return 0;
}
