def main():

    S = eval(input())

    if S[0] == "B":

        K = "WB"

    else:

        K = "BW"



    cnt = 0

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

        if S[i:i+2] == K:

            cnt += 1



    if S[0] == S[-1]:

        print((2 * cnt))

    else:

        print((1 + 2 * cnt))





main()

def main():

    S = eval(input())

    if S[0] == "B":

        K = "WB"

    else:

        K = "BW"

    cnt = S.count(K)



    if S[0] == S[-1]:

        print((2 * cnt))

    else:

        print((1 + 2 * cnt))





main()

def main():
    S = eval(input())
    if S[0] == "B":
        K = "WB"
    else:
        K = "BW"
    cnt = 0
    for i in range(len(S) - 1):
        if S[i : i + 2] == K:
            cnt += 1
    if S[0] == S[-1]:
        print((2 * cnt))
    else:
        print((1 + 2 * cnt))


main()

def main():
    S = eval(input())
    if S[0] == "B":
        K = "WB"
    else:
        K = "BW"
    cnt = S.count(K)
    if S[0] == S[-1]:
        print((2 * cnt))
    else:
        print((1 + 2 * cnt))


main()

-    cnt = 0 -    for i in range(len(S) - 1): -        if S[i : i + 2] == K: -            cnt += 1 +    cnt = S.count(K)