#!/usr/bin/env ruby

s = gets.chomp.chars
len = s.length - 1
count = 0

loop do
    f = true
    len.times do |i|
        if s[i] == 'B' and s[i+1] == 'W'
            s[i] = 'W'
            s[i+1] = 'B'
            f = false
            count += 1
            next
        end
    end
    break if f
end

puts count
