-- 左黒右白
local b = string.byte("B")

local s = io.read()
local s_len = s:len()
local s_bool_t = {}
for i = 1, s_len do
	if s:byte(i) == b then
		s_bool_t[i] = true
	else
		s_bool_t[i] = false
	end
end

local count_sum = 0
local count = 1
while count > 0 do
	count = 0
	for i = 1, s_len - 1 do
		if s_bool_t[i] and not s_bool_t[i + 1] then
			s_bool_t[i] = false
			s_bool_t[i + 1] = true
			count = count + 1
		end
	end
	count_sum = count_sum + count
end

print(count_sum)
