S = input()
dic = {s : S.count(s) for s in set(S)}
log = {}

def f(S):
    try:
        return log[S]
    
    except KeyError:
        if check(S):
            return 1
        else:
            res = len(S)
            for i in range(1, len(S) - 1):
                res = min(f(S[:i]) + f(S[i:]), res)
                log[S] = res
            return res
    
def check(S):
    flag = False
    for s in set(S):
        if S.count(s) % 2 == 1:
            if flag:
                return False
            else:
                flag = True
    return True

print(f(S))