from collections import Counter

S = eval(input())

ans = 0

c = Counter(S)

if c['W'] == 0 or c['B'] == 0:

    print((0))

    exit()

a = S[0]

while True:

    for i, s in enumerate(S):

        if s != a: break

    S = S[i:]

    c[a] -= i

    a = S[0]

    ans += 1

    if c['W'] == 0 or c['B'] == 0:break

print(ans)
S = eval(input())

ans = 0

for i in range(len(S) - 1):

    if S[i] != S[i+1]: ans+=1

print(ans)
from collections import Counter

S = eval(input())
ans = 0
c = Counter(S)
if c["W"] == 0 or c["B"] == 0:
    print((0))
    exit()
a = S[0]
while True:
    for i, s in enumerate(S):
        if s != a:
            break
    S = S[i:]
    c[a] -= i
    a = S[0]
    ans += 1
    if c["W"] == 0 or c["B"] == 0:
        break
print(ans)

S = eval(input())
ans = 0
for i in range(len(S) - 1):
    if S[i] != S[i + 1]:
        ans += 1
print(ans)

-from collections import Counter - -c = Counter(S) -if c["W"] == 0 or c["B"] == 0: -    print((0)) -    exit() -a = S[0] -while True: -    for i, s in enumerate(S): -        if s != a: -            break -    S = S[i:] -    c[a] -= i -    a = S[0] -    ans += 1 -    if c["W"] == 0 or c["B"] == 0: -        break +for i in range(len(S) - 1): +    if S[i] != S[i + 1]: +        ans += 1