s = gets.chomp.split("")
ookisa = s.size
i = 1
count = 0
until i == ookisa 
    if s[i] == "W" && s[i-1] == "B"
        s[i] = "B"
        s[i-1] = "W"
        count += 1
        if i >= 2
        i -= 1
        end
    else
        i += 1
    end
end
puts count
