S = {}

for w in string.gmatch(io.read(), "%a") do
  table.insert(S,w)
end

C = 0
mc = 0
bf = 0

for i=2, #S do
  p = table.concat(S,"",i-1,i);
  if p == "BW" then
    mc = mc + 1
    C = C + bf
    bf = 0
  else
    if p ~= "WB" then
      mc = 0
      
      if p == "WW" then
        C = C + 1
      end
    end

    if p == "BB" then
      bf = 1
    else
      bf = 0
    end
  end

  C = C + mc
end

print(C)
