board = eval(input())





changes = 1

currSeq = board[0]



for i in range(1, len(board)):

	current = board[i]

	if current != currSeq:

		changes += 1

		currSeq = current



print((changes - 1))
S = eval(input())

runs = 0

b = S[0] == 'B'

for s in S:

    if (s == 'B') != b:

        b = (s == 'B')

        runs += 1

print(runs)
board = eval(input())
changes = 1
currSeq = board[0]
for i in range(1, len(board)):
    current = board[i]
    if current != currSeq:
        changes += 1
        currSeq = current
print((changes - 1))

S = eval(input())
runs = 0
b = S[0] == "B"
for s in S:
    if (s == "B") != b:
        b = s == "B"
        runs += 1
print(runs)

-board = eval(input()) -changes = 1 -currSeq = board[0] -for i in range(1, len(board)): -    current = board[i] -    if current != currSeq: -        changes += 1 -        currSeq = current -print((changes - 1)) +S = eval(input()) +runs = 0 +b = S[0] == "B" +for s in S: +    if (s == "B") != b: +        b = s == "B" +        runs += 1 +print(runs)