S = input()

s_list = [i for i in S]

s_cand = [s_list]

while(True):

    pre = s_cand[:]

    del_list = []
    for t in range(len(s_cand)):
        for i in range(len(s_cand[t]) - 1):
            if s_cand[t][i] == s_cand[t][i + 1]:
                cand1 = s_cand[t][i] + s_cand[t][i + 1]
                kouho1 = s_cand[t][:]
                del kouho1[i : i + 2]
                kouho1.insert(i, cand1)
                s_cand.append(kouho1)
                if i + 2 < len(s_cand[t]):
                    cand2 = s_cand[t][i + 1] + s_cand[t][i + 2]
                    kouho2 = s_cand[t][:]
                    del kouho2[i + 1 : i + 3]
                    kouho2.insert(i + 1, cand2)
                    s_cand.append(kouho2)
                
                del_list.append(t)
                break

    del s_cand[del_list]
    
    if s_cand == pre:
        break

ans = 0
for i in s_cand:
    if len(i) > ans:
        ans = len(i)
print(ans)