s = input()
tmp = set()
ss = []
for x in s:
    if x in tmp:
        tmp.add(x)
    else:
        tmp.remove(x)
    ss.append(tmp)

n = [0]
for i in range(len(s)):
    n.append(0)
    n[i] = n[i-1] + 1
    for j in range(i-1, -1, -1):
        t = set(ss[j]).symmetric_difference(set(ss[i]))
        if len(t) <= 1 and n[j-1] + 1 < n[i]:
            n[i] = n[j-1]+1
print(n[len(s) - 1])
