S = list(input())

def long_repeat(line):
 
    max = 0
    cnt = 1
    
    for i in range(len(line)-1):
        if cnt > 1:
            cnt -= 1
            continue
        for j in range(i+1,len(line)):
            if line[i] == line[j]:
                cnt += 1
            else:
                break
        if max < cnt:
            max = cnt
 
    return max

s = long_repeat(S)

if len(S) <= s+1:
    print(s-1)
else:
    print(s)