D = [[1,0],[0,-1],[-1,0],[0,1]]

def dfs(x, y)
  if $fld[y][x] == "B"
    $flag_b = true 
    return
  end
  if $fld[y][x] == "W"
    $flag_w = true
    return
  end
  $vst[y][x] = true
  D.each do |dx, dy|
    nx, ny = x + dx, y + dy
    if nx >= 0 && nx < $w && ny >= 0 && ny < $h && $vst[ny][nx].nil?
      dfs(nx, ny)
    end
  end
end

loop do
  $w, $h = gets.split.map(&:to_i)
  break if $w == 0
  $fld = $h.times.map{ gets.chomp.split("") }
  cw = cb = 0
  for i in (0...$w)
    for j in (0...$h)
      $vst = $h.times.map{ [nil]*$w }
      $flag_b = $flag_w = false
      dfs(i, j) unless $fld[j][i] == "B" || $fld[j][i] == "W" 
      cb += 1 if $flag_b && !$flag_w
      cw += 1 if !$flag_b && $flag_w
    end
  end
  puts "#{cb} #{cw}"
end