s = gets.chomp.split("")
sum = 0
firstw = -1
while 1
  cnt = 0
  i = firstw + 1
  while i < s.length-1
    if s[i..(i+1)].join == "BW"
      s[i] = "W"
      s[i+1] = "B"
      cnt += 1
      i += 2
    else
      if s[i] == "W" && cnt == 0
        firstw = i
      end
      i += 1
    end
  end
  if cnt == 0
    break
  else
    sum += cnt
  end
end
puts sum