s = gets.chomp
a = s.split('').map{ |str| str == 'B' }

cnt = 0
while true
  continue = false
  (a.length - 1).times do |i|
    next unless a[i] && !a[i + 1]
    a[i] = false
    a[i + 1] = true
    cnt += 1
    continue = true
    break
  end
  break unless continue
end

puts cnt