#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

#A,B,K = [int(x) for x in input().split()]
S = input()

def hoge(input):
    new = []
    i = 0
    remove = False
    while i < len(input) - 1:
        if input[i] != input[i+1]:
            i = i + 2
            remove = True
        else:
            i = i + 1
            new.append(input[i])
    if i == len(input) - 1:
        new.append(input[-1])
    return new,remove

input = S
while True:
    input, remove = hoge(input)
    if not remove:
        break
print(len(S) - len(input))
