local w = string.byte("W")

local s = io.read()
local s_len = s:len()
local b_count = 0
local count = 0
local last_w_pos = 0
for i = 1, s_len do
	local is_w = s:byte(i) == w
	if b_count ~= 0 and is_w then
		count = count + b_count
		last_w_pos = last_w_pos + 1
	elseif is_w then
		last_w_pos = last_w_pos + 1
	else
		b_count = b_count + 1
	end
end

print(count)
