D = [[1,0],[0,-1],[-1,0],[0,1]]
 
def dfs(x, y)
  if $fld[y][x] == "B"
    $flag_b = true
    return
  elsif $fld[y][x] == "W"
    $flag_w = true
    return
  end
  $cnt += 1
  $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]
      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
  $vst = $h.times.map{ [false]*$w }
  for i in (0...$h)
    for j in (0...$w)
      if $fld[i][j] == "." && !$vst[i][j]
        $flag_b = $flag_w = false
        $cnt = 0
        dfs(j, i) 
        cb += $cnt if $flag_b && !$flag_w
        cw += $cnt if !$flag_b && $flag_w
      end
    end
  end
  puts "#{cb} #{cw}"
end