import sys
import math
import itertools

S = input()
H = []
for s in range(1, len(S)):
	H.append(s)

for k in reversed(range(len(S))):
	patern = list(itertools.combinations(H, k))
	for p in patern:
		Sp = []
		left = 0
		for i in p:
			Sp.append(S[left:i])
			left = i
		Sp.append(S[p[-1]:len(S)])

		impossible = False
		for i in range(len(Sp)-1):
			if Sp[i] == Sp[i+1]:
				impossible = True
				break
		if impossible == False:
			print(k+1)
			sys.exit()
print(0)

