#ABC047 C - 一次元リバーシ / 1D Reversi

S = eval(input())

cur_s = ''

SS=[] 

for i,s in enumerate(S):

    if i==0:

        cur_s = s

        SS.append(s)

        continue

    if i==len(S):

        if cur_s == s:

            continue

        else:

            SS.append(s)

            continue



    if cur_s == s:

        continue

    else:

        SS.append(s)

        cur_s = s



n = len(SS)

m = n//2

if n==1:

    print((0))

    exit()



if n%2==1:

    print((m*2))

else:

    print((((n//2)*2)-1))

si = lambda: eval(input())

ni = lambda: int(eval(input()))

nm = lambda: list(map(int, input().split()))

nl = lambda: list(map(int, input().split()))

s=eval(input())

cur=s[0]

counter=1

for i,ss in enumerate(s):

    if i==0:

        continue

    if ss!=cur:

        counter+=1

        cur=ss

print((counter-1))
# ABC047 C - 一次元リバーシ / 1D Reversi
S = eval(input())
cur_s = ""
SS = []
for i, s in enumerate(S):
    if i == 0:
        cur_s = s
        SS.append(s)
        continue
    if i == len(S):
        if cur_s == s:
            continue
        else:
            SS.append(s)
            continue
    if cur_s == s:
        continue
    else:
        SS.append(s)
        cur_s = s
n = len(SS)
m = n // 2
if n == 1:
    print((0))
    exit()
if n % 2 == 1:
    print((m * 2))
else:
    print((((n // 2) * 2) - 1))

si = lambda: eval(input())
ni = lambda: int(eval(input()))
nm = lambda: list(map(int, input().split()))
nl = lambda: list(map(int, input().split()))
s = eval(input())
cur = s[0]
counter = 1
for i, ss in enumerate(s):
    if i == 0:
        continue
    if ss != cur:
        counter += 1
        cur = ss
print((counter - 1))

-# ABC047 C - 一次元リバーシ / 1D Reversi -S = eval(input()) -cur_s = "" -SS = [] -for i, s in enumerate(S): +si = lambda: eval(input()) +ni = lambda: int(eval(input())) +nm = lambda: list(map(int, input().split())) +nl = lambda: list(map(int, input().split())) +s = eval(input()) +cur = s[0] +counter = 1 +for i, ss in enumerate(s): -        cur_s = s -        SS.append(s) -    if i == len(S): -        if cur_s == s: -            continue -        else: -            SS.append(s) -            continue -    if cur_s == s: -        continue -    else: -        SS.append(s) -        cur_s = s -n = len(SS) -m = n // 2 -if n == 1: -    print((0)) -    exit() -if n % 2 == 1: -    print((m * 2)) -else: -    print((((n // 2) * 2) - 1)) +    if ss != cur: +        counter += 1 +        cur = ss +print((counter - 1))