import sys
d = input().strip()

count = 0

if len(d) == 1:
    print(0)
    sys.exit(0)

while True:
    new = ''
    flag = False
    i = 0
    while i < len(d) - 1:
        if d[i] == d[i+1]:
            new += d[i]
        else:
            flag = True
        i += 1
    if flag is False:
        break
    count += 1
    d = new
    if len(d) <= 1:
        break

print(count)
