s = eval(input())

prev = ans = -1

for c in s:

    if prev != c:

        prev = c

        ans += 1

print(ans)
s = eval(input())

print((s.count('BW') + s.count("WB")))
s = eval(input())
prev = ans = -1
for c in s:
    if prev != c:
        prev = c
        ans += 1
print(ans)

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

-prev = ans = -1 -for c in s: -    if prev != c: -        prev = c -        ans += 1 -print(ans) +print((s.count("BW") + s.count("WB")))