s = eval(input())

print((sum((s[i] != s[i+1] for i in range(len(s)-1)))))

s = eval(input())

print((s.count("BW")+s.count("WB")))
s = eval(input())
print((sum((s[i] != s[i + 1] for i in range(len(s) - 1)))))

s = eval(input())
print((s.count("BW") + s.count("WB")))

-print((sum((s[i] != s[i + 1] for i in range(len(s) - 1))))) +print((s.count("BW") + s.count("WB")))