import itertools

s=str(input())
k=[]
for i in range(len(s)-1):
    k.append(len(s)-1-i)
#k=[i+1 for i in range(len(s)-1)]

for i in k:
    c=list(itertools.combinations([i for i in range(len(s)-1)],i))
    for j in c:
        for m in range(len(j)):
            if len(j)==1:
                si=[s[:j[m]+1],s[j[m]+1:]]
            else:
                if m==0:
                    si=[s[:j[m]+1]]
                else:
                    si.append(s[j[m-1]+1:j[m]+1])
                if m==len(j)-1:
                    si.append(s[j[m]+1:])
            che1=False
            for n in range(len(si)-1):
                if si[n]==si[n+1]:
                    che1=True
                    break
            if che1==True:
                break
        che=False
        for m in range(len(si)-1):
            if si[m]==si[m+1]:
                che=True
        if che==False:
            break
    if che==False:
        break
print(i+1)