S = STDIN.gets.chomp.split('').map {|s| s == 'B'}

index = 0
cnt = 0
while true
  break if index == S.length - 1
  # puts index

  si = S[index]
  si1 = S[index+1]
  if si == true && si1 == false
    S[index] = false
    S[index+1] = true
    cnt += 1
    if index == 0
      index += 1
    else
      index -= 1
    end
  else
    index += 1
  end
end

puts cnt
