import copy
import itertools
S = input()

K = 0
S__ = []
flag = False
prev = -1
for i in range(len(S)):
    S_ = list(itertools.combinations(range(len(S) - 1), i))
    for j in S_:
        if len(j) == 0:
            continue
        else:
            index = 0
            S__ = []
            buff = ""
            for k in range(len(S)):
                buff += S[k]
                if index >= len(j):
                    buff += S[k+1:]
                    S__.append(buff)
                    break
                if k == j[index]:
                    S__.append(buff)
                    buff = ""
                    index += 1
                    continue
            for k in range(len(S__) - 1):
                if S__[k] == S__[k + 1]:
                    break
                elif k == len(S__) - 2:
                    K = len(S__)
                    flag = True
            if flag:
                flag = False
                break
    if K == prev:
        print(K)
        exit(0)
    else:
        prev = K
    




    
