s=list(eval(input()))

sl=len(s)

cnt=0

for i in range(sl-1):

    if s[i]=="W":

        if s[i+1]=="B":

            cnt+=1

    elif s[i]=="B":

        if s[i+1]=="W":

            cnt+=1

print(cnt)
s=list(eval(input()))

sl=len(s)

cnt=0

for i in range(1,sl):

    if s[i]!=s[i-1]:

        cnt+=1

print(cnt)

        
s = list(eval(input()))
sl = len(s)
cnt = 0
for i in range(sl - 1):
    if s[i] == "W":
        if s[i + 1] == "B":
            cnt += 1
    elif s[i] == "B":
        if s[i + 1] == "W":
            cnt += 1
print(cnt)

s = list(eval(input()))
sl = len(s)
cnt = 0
for i in range(1, sl):
    if s[i] != s[i - 1]:
        cnt += 1
print(cnt)

-for i in range(sl - 1): -    if s[i] == "W": -        if s[i + 1] == "B": -            cnt += 1 -    elif s[i] == "B": -        if s[i + 1] == "W": -            cnt += 1 +for i in range(1, sl): +    if s[i] != s[i - 1]: +        cnt += 1