# その時点で消せる分を消す
import sys

S = input()  # str

def destroy_step(charst):
    if len(charst) == 1:
        return charst, False
    initial = len(charst)
    dst = ""
    next = True

    for i in range(initial-1):

        if next:
            a = charst[i]
            b = charst[i+1]
            if a != b:
                next = False
            else:
                dst+=a
                next = True
                if i == initial-2:
                    dst+=b
        else:
            next = True
        if i == initial-3:
            if next is False:
                dst+=charst[-1]

    last = len(dst)
    flag = True
    if initial - last == 0:
        flag = False
    return dst, flag
dst = S
flag = True
while flag:
    dst, flag = destroy_step(dst)
print(len(S)-len(dst))
sys.exit()
