S = input()
A = [[0 for i in range(26)] for j in range(len(S) + 1)]
for i in range(1,len(S)+1):
	c = S[i-1]
	A[i] = [n for n in A[i-1]]
	A[i][ord(c)-ord('a')] += 1

memo = {}
def isPal(start,end):
	if (start,end) in memo:
		return memo[(start,end)]
	l = [(A[end][i] - A[start][i]) % 2 for i in range(26)]
	odd = l.count(1)
	memo[(start,end)] = (odd <= 1)
	return odd <= 1

memo2 = [[-1 if i != j else 1 for i in range(len(S))] for j in range(len(S))]
def partition(start,end):
	if memo2[start][end-1] > 0:
		return memo2[start,end-1]
	elif isPal(start,end):
		memo2[start][end-1] = 1
		return 1
	else:
		ret = 1000000
		for s2 in [s for s in range(start+1, end) if isPal(start,s)]:
			memo2[start][s2-1] = 1
			if memo2[s2][end-1] > 0:
				ret = min(ret, memo2[s2][end-1] + 1)
			else:
				a = partition(s2,end)
				ret = min(ret, a + 1)
			if ret == 2:
				break
		memo2[start][end-1] = ret
		return ret

print(partition(0,len(S)))